fix(opencode): update xai provider

This commit is contained in:
Aiden Cline 2026-06-01 01:55:48 -05:00
commit 67223eaa53
7 changed files with 144 additions and 107 deletions

View file

@ -54,7 +54,7 @@
"@ai-sdk/provider-utils": "4.0.23",
"@ai-sdk/togetherai": "2.0.41",
"@ai-sdk/vercel": "2.0.39",
"@ai-sdk/xai": "3.0.82",
"@ai-sdk/xai": "3.0.92",
"@aws-sdk/credential-providers": "3.993.0",
"@effect/opentelemetry": "catalog:",
"@effect/platform-node": "catalog:",

View file

@ -89,7 +89,7 @@
"@ai-sdk/provider": "3.0.8",
"@ai-sdk/togetherai": "2.0.41",
"@ai-sdk/vercel": "2.0.39",
"@ai-sdk/xai": "3.0.82",
"@ai-sdk/xai": "3.0.92",
"@aws-sdk/credential-providers": "3.993.0",
"@clack/prompts": "1.0.0-alpha.1",
"@effect/opentelemetry": "catalog:",

View file

@ -0,0 +1,53 @@
import { describe, expect, test } from "bun:test"
import { createXai } from "@ai-sdk/xai"
describe("@ai-sdk/xai", () => {
test("sends inline PDF attachments through the Responses API", async () => {
let input: unknown
const handle = async (_url: Parameters<typeof fetch>[0], options?: Parameters<typeof fetch>[1]) => {
input = JSON.parse(String(options?.body)).input
return new Response(
JSON.stringify({
object: "response",
output: [],
status: "completed",
usage: { input_tokens: 0, output_tokens: 0 },
}),
{ status: 200, headers: { "content-type": "application/json" } },
)
}
const xai = createXai({
apiKey: "test",
fetch: Object.assign(handle, { preconnect: fetch.preconnect.bind(fetch) }),
})
await xai.responses("grok-4").doGenerate({
prompt: [
{
role: "user",
content: [
{
type: "file",
mediaType: "application/pdf",
filename: "sample.pdf",
data: new Uint8Array([0x25, 0x50, 0x44, 0x46]),
},
],
},
],
})
expect(input).toEqual([
{
role: "user",
content: [
{
type: "input_file",
filename: "sample.pdf",
file_data: "data:application/pdf;base64,JVBERg==",
},
],
},
])
})
})