GPT-OSS 20B API
Available CheapestGPT-OSS 20B is the 21B-parameter sibling of GPT-OSS 120B (3.6B active parameters, MXFP4) and the model Groq recommends in place of llama-3.1-8b-instant. It reasons before answering, calls tools and returns JSON. On our 2026-09-22 check it passed all five of our tool-call, JSON, arithmetic, code and instruction tests and streamed at about 100 tokens per second with eight concurrent requests all answered.
Quickstart
Set INFERENCE_API_KEY to your key from the API Keys page, then run:
curl https://api.inferenceapis.com/v1/chat/completions \
-H "Authorization: Bearer $INFERENCE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-oss-20b",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello! What can you do?"}
]
}'
import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.inferenceapis.com/v1",
api_key=os.environ["INFERENCE_API_KEY"],
)
response = client.chat.completions.create(
model="openai/gpt-oss-20b",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello! What can you do?"},
],
)
print(response.choices[0].message.content)
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.inferenceapis.com/v1",
apiKey: process.env.INFERENCE_API_KEY,
});
const response = await client.chat.completions.create({
model: "openai/gpt-oss-20b",
messages: [
{ role: "system", content: "You are a helpful assistant." },
{ role: "user", content: "Hello! What can you do?" },
],
});
console.log(response.choices[0].message.content);
When to use it
- You are replacing llama-3.1-8b-instant on Groq and want the small model Groq itself recommends
- Classification, extraction and short assistant replies where cost per call matters more than depth
- Multi-step coding or agent work; use GPT-OSS 120B or DeepSeek V4 Flash
- You need more than 131K tokens of context
What it costs in practice
| Workload | Cost |
|---|---|
| Chat assistant — 10,000 turns of 800 tokens in, 300 out | $0.89 |
| Long prompts or RAG — 10,000 requests of 8,000 in, 500 out | $4.15 |
| Generation-heavy — 10,000 requests of 500 in, 2,000 out | $4.00 |
Computed from the live rates below. This is a reasoning model, and thinking is billed as output, so real output counts run above the visible answer; see controlling reasoning to keep that down. There is no subscription or minimum; new accounts start with free credit.
Endpoint
Content-Type: application/json
/openai/v1/… is accepted too, so Groq-style base URLs work with only the host changed.
Model IDs and aliases
Send any of these as model; they all resolve to this model and bill at its rate.
| ID | Note |
|---|---|
openai/gpt-oss-20b | Canonical |
gpt-oss-20b | Alias |
Request body
| Parameter | Type | Description |
|---|---|---|
model required |
string | Model ID: openai/gpt-oss-20b — also accepted: gpt-oss-20b |
messages required |
array | Conversation so far. Each item has a role (system, user or assistant) and content. |
max_tokens |
integer | Maximum number of tokens to generate (includes reasoning tokens — use a few hundred or more). |
temperature |
number | Sampling temperature. Higher values give more varied output. |
top_p |
number | Nucleus sampling cutoff. |
stream |
boolean | Stream the response as server-sent events. The final chunk includes usage. |
tools |
array | Tool definitions for function calling (OpenAI format). |
response_format |
object | {"type": "json_object"} for JSON mode. |
stop |
string | array | Sequences where the model stops generating. |
seed |
integer | Seed for more reproducible sampling. |
Response
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"model": "openai/gpt-oss-20b",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hi! I can answer questions, write and edit text, help with code and more.",
"reasoning": "The user is greeting me and asking about capabilities..."
},
"finish_reason": "stop"
}
],
"usage": { "prompt_tokens": 28, "completion_tokens": 17, "total_tokens": 45 }
}
Controlling reasoning
resp = client.chat.completions.create(
model="openai/gpt-oss-20b",
reasoning_effort="none", # thinking off
messages=[{"role": "user", "content": "Extract the invoice number from: ..."}],
max_tokens=500,
)Token counts are single measurements from September 17, 2026 and vary with the question; the direction is what matters.
Pricing
| Input | $0.04 / 1M tokens |
| Output | $0.19 / 1M tokens |
| Billing | Pay as you go from prepaid credits. No subscription, no daily request or token cap. See all pricing. |
Notes
- This is a reasoning model: set
max_tokensto at least a few hundred, or sendreasoning_effort: "none"to keep thinking to a minimum. - The response includes a
reasoning_contentfield alongsidecontent.
Compare GPT-OSS 20B with…
Errors
Errors use the OpenAI envelope: {"error": {"message", "type", "code"}}. 401 missing or invalid key · 402 insufficient_balance · 404 model_not_found · 503 model_unavailable · 502 backend error, safe to retry. Full table with what to retry: API documentation. Errors from other providers: provider error reference.
