Use Inference APIs with Vercel AI SDK
Use @ai-sdk/openai-compatible to create a provider for Inference APIs; then streamText, generateText and tool calling work as with any provider.
Settings
| Setting | Value |
|---|---|
| Base URL | https://api.inferenceapis.com/v1 (also /openai/v1) |
| API key | From API Keys; send as Authorization: Bearer … |
| Chat model ids | openai/gpt-oss-120b, deepseek-ai/DeepSeek-V4-Flash, zai-org/GLM-5.3-Flash, meta-llama/Llama-3.3-70B-Instruct-Turbo — all models |
| Audio model ids | openai/whisper-large-v3 (transcription), hexgrad/Kokoro-82M (speech) |
Configuration
Install
npm install ai @ai-sdk/openai-compatibleProvider + streamText
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
import { streamText } from "ai";
const inferenceapis = createOpenAICompatible({
name: "inferenceapis",
baseURL: "https://api.inferenceapis.com/v1",
apiKey: process.env.INFERENCE_API_KEY,
});
const result = streamText({
model: inferenceapis("openai/gpt-oss-120b"),
prompt: "Write a limerick about rate limits.",
});
for await (const chunk of result.textStream) process.stdout.write(chunk);Verify
Smoke test
node -e "console.log('see snippet')"Gotchas
- Use inferenceapis.chatModel(id) if your SDK version distinguishes chat and completion models.
If something fails
401 — key missing or wrong · 402 insufficient_balance — add credits on Billing · 404 model_not_found — check the id against the model list (aliases such as gpt-oss-120b work too) · 503 model_unavailable — the model is being enabled. Full details in the API docs.
