opencode-openai-compatible
v1.0.9
Published
OpenCode-compatible AI SDK provider with tool call compatibility fixes
Maintainers
Readme
opencode-openai-compatible
OpenCode-compatible AI SDK provider and plugin with streaming, reasoning, and tool call support.
Features
- Streaming with Reasoning: Full support for
reasoning_contentin streaming responses - Tool Call Support: Proper handling of function calls without crashes
- finishReason Format: Returns correct string format (
stop,length, etc.) - Plugin Mode: OpenCode plugin architecture for seamless integration
- Legacy Provider Mode: AI SDK provider for direct usage
Installation
bun add opencode-openai-compatiblePlugin Mode (Recommended)
import { createOpenCodeCompatiblePlugin } from 'opencode-openai-compatible';
const plugin = createOpenCodeCompatiblePlugin({
baseURL: 'http://127.0.0.1:8045',
apiKey: 'your-api-key',
});Legacy Provider Mode
import { createOpenCodeCompatible } from 'opencode-openai-compatible';
import { generateText } from 'ai';
const provider = createOpenCodeCompatible({
apiKey: 'your-api-key',
baseURL: 'http://localhost:6608/v1',
});
const { text } = await generateText({
model: provider.chatModel('gemini-3-flash'),
prompt: 'Hello, world!',
});Streaming
import { streamText } from 'ai';
const { textStream } = await streamText({
model: provider.chatModel('gemini-3-pro-high'),
prompt: 'Tell me a story',
});
for await (const chunk of textStream) {
process.stdout.write(chunk);
}Supported Models
gemini-3-flashgemini-3-progemini-3-pro-highclaude-sonnet-4-5claude-sonnet-4-5-thinkingclaude-opus-4-5-thinking
Testing
bun test
bun test tests/e2e/api.test.tsLicense
MIT
