Skip to content

Instantly share code, notes, and snippets.

@K-Mistele
Created September 4, 2025 17:33
Show Gist options
  • Select an option

  • Save K-Mistele/9beaf10c921866d2701538704999d299 to your computer and use it in GitHub Desktop.

Select an option

Save K-Mistele/9beaf10c921866d2701538704999d299 to your computer and use it in GitHub Desktop.
Opencode Zod schema validation issue
import { createOpencodeClient, createOpencodeServer } from "../packages/sdk/js/src"
const server = await createOpencodeServer({ port: 9090 })
try {
const client = await createOpencodeClient({ baseUrl: server.url })
const { data: session } = await client.session.create({ body: { title: "test session" } })
if (!session) throw new Error("Unable to create new session")
const { data: result, error } = await client.session.prompt({
path: { id: session.id },
body: {
parts: [{ type: "text", text: "What files are in the current directory?" }],
model: {
providerID: "anthropic",
modelID: "claude-sonnet-4-20250514",
},
},
})
if (result) console.log(result)
else if (error) throw error
} catch (error: any) {
console.error("error" in error ? error.error : error)
} finally {
await server.close()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment