Skip to content

Commit

Permalink
Feature: add a way to set Cloudflare AI Gateway options (#14)
Browse files Browse the repository at this point in the history
* add a way to set gateway options

* add documentation
  • Loading branch information
laulauland authored Feb 6, 2025
1 parent 08bf67e commit b76c94b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/ai-provider/src/workersai-chat-language-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ export class WorkersAIChatLanguageModel implements LanguageModelV1 {

const response = await this.config.binding.run(args.model, {
messages: args.messages,
},
{
gateway: this.settings.gateway
});

if (response instanceof ReadableStream) {
Expand Down
4 changes: 4 additions & 0 deletions packages/ai-provider/src/workersai-chat-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ export interface WorkersAIChatSettings {
Defaults to `false`.
*/
safePrompt?: boolean;
/**
* Optionally set Cloudflare AI Gateway options.
*/
gateway?: GatewayOptions
}

0 comments on commit b76c94b

Please sign in to comment.