@ai-sdk/openai-compatible.
Before you start: create a Fortytwo API key and buy credits — see Quickstart, step 1. Keep the key on your server: the API cannot be called from a web page in the browser.
Install
zod is needed only for tools and structured output.
Put your key in an environment variable:
Create the provider
fortytwo.ts
includeUsageadds token counts to streamed responses.supportsStructuredOutputssends JSON schemas in strict mode, which the Fortytwo API supports.fortytwo("qwen/qwen3.8-27b")takes any model ID from Models.
Generate text
reasoningText holds the model’s reasoning. reasoningEffort is sent as reasoning_effort; the accepted values and the default are in Models.
Stream
Call tools
stopWhen lets the model call a tool, read the result and answer in the same call.
Get structured output
Send an image
Limits
- Chat Completions only: the AI SDK’s OpenAI Responses provider (
@ai-sdk/openaiwithopenai.responses(...)) does not work with the Fortytwo API. Use@ai-sdk/openai-compatibleas above. - Requests go out with the AI SDK’s own
User-Agent; add aheaderssetting tocreateOpenAICompatibleif you want to tag your traffic.
Something not working with your agent, or using one we have not listed? Tell us in the platform: Feedback for ideas and small bugs, Contact support if it blocks your work, or Report a security issue.