Skip to content

Commit a5b47d1

Browse files
committed
fix: bring back body
1 parent bb1e7a4 commit a5b47d1

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

packages/framework/src/providers/openai.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export type OpenAIProviderOptions = {
2323
* otherwise you will get an error. Otherwise, use the one from `openai_response_functions.js` instead.
2424
*/
2525
export const openai = (options: OpenAIProviderOptions = {}): Provider => {
26-
const { model = 'gpt-4o', options: clientOptions } = options
26+
const { model = 'gpt-4o', options: clientOptions, body = {} } = options
2727
const client = new OpenAI(clientOptions)
2828

2929
return {
@@ -36,6 +36,7 @@ export const openai = (options: OpenAIProviderOptions = {}): Provider => {
3636
tools: mappedTools.length > 0 ? mappedTools : undefined,
3737
temperature,
3838
response_format: responseAsStructuredOutput(response_format),
39+
...body,
3940
})
4041

4142
const message = response.choices[0].message

packages/framework/src/providers/openai_response_functions.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export type OpenAIProviderOptions = BaseOpenAIProviderOptions & {
3232
* but tools as response to enforce the right JSON schema.
3333
*/
3434
export const openai = (options: OpenAIProviderOptions): Provider => {
35-
const { model, options: clientOptions, strictMode = false } = options
35+
const { model, options: clientOptions, strictMode = false, body = {} } = options
3636
const client = new OpenAI(clientOptions)
3737

3838
return {
@@ -45,6 +45,7 @@ export const openai = (options: OpenAIProviderOptions): Provider => {
4545
messages,
4646
temperature,
4747
tool_choice: 'required',
48+
...body,
4849
})
4950

5051
/**

packages/framework/src/providers/openrouter.ts

+3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export const openrouter = (options: OpenRouterOptions = {}): Provider => {
2525
model = 'meta-llama/llama-3.1-405b-instruct',
2626
structured_output = true,
2727
options: clientOptions,
28+
body = {},
2829
} = options
2930
const openAiOptions = {
3031
model,
@@ -38,11 +39,13 @@ export const openrouter = (options: OpenRouterOptions = {}): Provider => {
3839
* support structured output.
3940
*/
4041
body: {
42+
...body,
4143
provider: {
4244
/**
4345
* @see https://openrouter.ai/docs/provider-routing#required-parameters-_beta_
4446
*/
4547
require_parameters: true,
48+
...body?.provider,
4649
},
4750
},
4851
}

0 commit comments

Comments
 (0)