Skip to content

Commit d6940af

Browse files
committed
align google api key fallback, document model options
1 parent 3f86b3e commit d6940af

4 files changed

Lines changed: 25 additions & 4 deletions

File tree

docs/docs/advanced/image-generation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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

170170
Or use `setKeys()` - see [quick start](../quick-start.md#api-keys).
171171

docs/docs/concepts/composition.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff 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

docs/docs/quick-start.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,5 +140,3 @@ const workflow = compose(
140140

141141
await workflow("what's the weather?");
142142
```
143-
144-
Next: [Threads](concepts/threads.md)

threads/src/image.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)