Skip to content

Commit

Permalink
feat (docs): add example for headers
Browse files Browse the repository at this point in the history
  • Loading branch information
lgrammel committed Jun 27, 2024
1 parent 5edc611 commit 6851542
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions content/docs/03-ai-sdk-core/25-settings.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,25 @@ An optional abort signal that can be used to cancel the call.
### `headers`

Additional HTTP headers to be sent with the request. Only applicable for HTTP-based providers.

You can use the request headers to provide additional information to the provider,
depending on what the provider supports. For example, some observability providers support
headers such as `Prompt-Id`.

```ts
import { openai } from '@ai-sdk/openai';

const result = await generateText({
model: openai('gpt-3.5-turbo'),
prompt: 'Invent a new holiday and describe its traditions.',
headers: {
'Prompt-Id': 'my-prompt-id',
},
});
```

<Note>
The `headers` setting is for request-specific headers. You can also set
`headers` in the provider configuration. These headers will be sent with every
request made by the provider.
</Note>

0 comments on commit 6851542

Please sign in to comment.