How to call gpt-oss-120b through an API

gpt-oss-120b is OpenAI's open-weight model, so besides running it yourself you can call it through hosts that serve it. Our AI Chat Answer API runs gpt-oss-120b on Cloudflare and charges $0.01 per answer, with no account or API key: you POST a prompt or a list of messages and get the answer back as text.

Try it free AI Chat Answer API — one answer from a large open model · $0.01 / call

About the model

gpt-oss-120b is the larger of the two open-weight models OpenAI released in 2025, under the Apache 2.0 licence. Because the weights are public, many hosts run it, and you can run it yourself if you have a large enough GPU.

It is a reasoning model: it is good at step-by-step answers, explanations and code, and it answers in many languages.

Request fields

FieldValue
promptA single question or instruction (or use messages instead)
messagesUp to 20 items like {"role": "user", "content": "..."}
systemOptional instructions for tone, format or role
max_tokens16 to 2,000, default 1,000
temperature0 to 1.5; lower is more focused
Input limit12,000 characters in total

Python

pay_post stands for your x402 v2 client, which pays the $0.01 in USDC on Base and repeats the request.

import requests

URL = "https://iamai.markets/api/x402/services/3zGQQ2mdFxk1"
body = {
    "system": "Answer in at most three sentences.",
    "prompt": "Why does ice float on water?",
    "temperature": 0.3,
    "max_tokens": 300,
}

print(requests.post(URL, json=body, timeout=90).status_code)  # 402

# r = pay_post(URL, json=body)
# result = r.json()["result"]
# print(result["answer"], result["model"], result["finish_reason"])

curl

curl -X POST https://iamai.markets/api/x402/services/3zGQQ2mdFxk1 \
  -H "Content-Type: application/json" \
  -d '{"prompt": "Write a regex that matches a UK postcode", "max_tokens": 500}'

Other ways to run gpt-oss-120b

RouteGood forTrade-off
Self-host (vLLM, Ollama)Full control, no per-call costNeeds a large GPU and upkeep
Hosts like Groq, Together AI, OpenRouter, Cloudflare Workers AIOpenAI-style endpoints, streamingAccount, key and per-token billing
AI Chat Answer API (iamai.markets)Agents and scripts that pay per answerNo streaming or tool calling; own request format

The product

Questions

Is your endpoint OpenAI-compatible?

No. It takes prompt or messages and returns answer, model and finish_reason. OpenAI SDKs won't work against it directly.

What does finish_reason "length" mean?

The answer hit max_tokens and was cut off. Raise max_tokens (up to 2,000) or ask for a shorter answer.

Can I see the model's reasoning?

The API returns the final answer text only.

Related

Updated 2026-12-01