File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -165,7 +165,7 @@ Environment variables are detected automatically.
165165| ----------| ---------|
166166| openai | ` OPENAI_API_KEY ` |
167167| xai | ` XAI_API_KEY ` |
168- | google | ` GEMINI_API_KEY ` |
168+ | google | ` GEMINI_API_KEY ` or ` GOOGLE_AI_API_KEY ` |
169169
170170Or use ` setKeys() ` - see [ quick start] ( ../quick-start.md#api-keys ) .
171171
Original file line number Diff line number Diff line change @@ -46,6 +46,28 @@ Supported providers:
4646- anthropic: ` anthropic/<model-identifier> `
4747- google: ` google/<model-identifier> `
4848
49+ ### With Custom API Key
50+
51+ ``` typescript
52+ const result = await model ({
53+ model: " openai/gpt-4o" ,
54+ apiKey: " sk-different-key" ,
55+ })(" explain quantum physics" );
56+ ```
57+
58+ Useful for multi-tenant apps where each user has their own key.
59+
60+ ### With Custom Base URL
61+
62+ ``` typescript
63+ const result = await model ({
64+ model: " openai/gpt-4o" ,
65+ baseUrl: " https://my-proxy.example.com/v1" ,
66+ })(" explain quantum physics" );
67+ ```
68+
69+ Point to a proxy, gateway, or OpenAI-compatible API.
70+
4971### With System Message
5072
5173``` typescript
Original file line number Diff line number Diff line change @@ -140,5 +140,3 @@ const workflow = compose(
140140
141141await workflow (" what's the weather?" );
142142```
143-
144- Next: [ Threads] ( concepts/threads.md )
Original file line number Diff line number Diff line change @@ -12,7 +12,8 @@ const getApiKey = (provider: string): string => {
1212 return getKey ( provider ) ;
1313 } catch {
1414 const envVar = providerKeyEnvVars [ provider ] ;
15- const key = envVar ? process . env [ envVar ] || "" : "" ;
15+ const fallbackEnvVar = provider === "google" ? "GOOGLE_AI_API_KEY" : undefined ;
16+ const key = envVar ? process . env [ envVar ] || ( fallbackEnvVar ? process . env [ fallbackEnvVar ] : "" ) || "" : "" ;
1617 if ( ! key ) throw new Error ( `No API key found for provider: ${ provider } ` ) ;
1718 return key ;
1819 }
You can’t perform that action at this time.
0 commit comments