Skip to content

Commit 5823161

Browse files
[AIG]Log ID example (#21926)
* Log ID example * description
1 parent 46d2ed9 commit 5823161

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/content/docs/ai-gateway/integrations/vercel-ai-sdk.mdx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,25 @@ const anthropic = createAnthropic({
4040
If you're using the Google AI Studio provider in AI SDK, you need to append `/v1beta` to your Google AI Studio-compatible AI Gateway URL to avoid errors. The `/v1beta` path is required because Google AI Studio's API includes this in its endpoint structure, and the AI SDK sets the model name separately. This ensures compatibility with Google's API versioning.
4141

4242
```typescript
43-
import { createGoogleGenerativeAI } from '@ai-sdk/google';
43+
import { createGoogleGenerativeAI } from "@ai-sdk/google";
4444

4545
const google = createGoogleGenerativeAI({
4646
baseURL: `https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/google-ai-studio/v1beta`,
4747
});
4848
```
4949

50+
### Retrieve `log id` from AI SDK
51+
52+
You can access the AI Gateway `log id` from the response headers when invoking the SDK.
53+
54+
```typescript
55+
const result = await generateText({
56+
model: anthropic("claude-3-sonnet-20240229"),
57+
messages: [],
58+
});
59+
console.log(result.response.headers["cf-aig-log-id"]);
60+
```
61+
5062
### Other providers
5163

5264
For other providers that are not listed above, you can follow a similar pattern by creating a custom instance for any AI provider, and passing your AI Gateway URL. For help finding your provider-specific AI Gateway URL, refer to the [Supported providers page](/ai-gateway/providers).

0 commit comments

Comments
 (0)