API Reference

OpenAI-compatible

Drop-in replacement for the OpenAI API. Change base_url and your key — everything else stays the same.

Quick Start

Get running in under 2 minutes:

Cursor / Windsurf / Cline

Settings → Models → OpenAI-compatible provider
Base URL:  https://fair-price.ai/api/v1
API Key:   fp-sk-your_key_here
Model:     Qwen/Qwen3-235B-A22B-Instruct-2507-FP8

Python

pip install openai
from openai import OpenAI

client = OpenAI(
    base_url="https://fair-price.ai/api/v1",
    api_key="fp-sk-your_key_here",
)

response = client.chat.completions.create(
    model="Qwen/Qwen3-235B-A22B-Instruct-2507-FP8",
    messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)

Authentication

Pass your API key as a Bearer token in the Authorization header. Create keys in Dashboard → API Keys.

HTTP header
Authorization: Bearer fp-sk-your_key_here
Keep your API key secret. Never expose it in client-side code or public repos. Keys can be revoked from the dashboard at any time.

Models

Two frontier models available. Pass the full model ID in your request.

Model IDDescriptionBest for
Qwen/Qwen3-235B-A22B-Instruct-2507-FP8235B MoE, 22B active paramsCoding, reasoning, agentic tasks
moonshotai/Kimi-K2-Instruct1T MoE, long-contextLong docs, multi-file codebases

Full model list via API: GET https://fair-price.ai/api/v1/models

Chat Completions

POST
/api/v1/chat/completions

Identical to OpenAI Chat Completions. All standard parameters are supported.

Request body

application/json
{
  "model": "Qwen/Qwen3-235B-A22B-Instruct-2507-FP8",
  "messages": [
    { "role": "system", "content": "You are a helpful assistant." },
    { "role": "user",   "content": "Explain async/await in Python." }
  ],
  "temperature": 0.7,   // optional, 0–2
  "max_tokens": 2048,   // optional
  "stream": false       // set true for streaming
}

Response

200 OK
{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1748000000,
  "model": "Qwen/Qwen3-235B-A22B-Instruct-2507-FP8",
  "choices": [
    {
      "index": 0,
      "message": { "role": "assistant", "content": "..." },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 42,
    "completion_tokens": 120,
    "total_tokens": 162
  }
}

Streaming

stream: true — server-sent events
data: {"id":"chatcmpl-abc","object":"chat.completion.chunk","choices":[{"delta":{"content":"Hello"},"index":0}]}

data: [DONE]

Examples

curl

shell
curl https://fair-price.ai/api/v1/chat/completions \
  -H "Authorization: Bearer fp-sk-your_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "Qwen/Qwen3-235B-A22B-Instruct-2507-FP8",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

Node.js / TypeScript

npm install openai
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://fair-price.ai/api/v1",
  apiKey: "fp-sk-your_key_here",
});

const res = await client.chat.completions.create({
  model: "Qwen/Qwen3-235B-A22B-Instruct-2507-FP8",
  messages: [{ role: "user", content: "Hello!" }],
});
console.log(res.choices[0].message.content);

Streaming (Python)

python
from openai import OpenAI

client = OpenAI(
    base_url="https://fair-price.ai/api/v1",
    api_key="fp-sk-your_key_here",
)

with client.chat.completions.stream(
    model="Qwen/Qwen3-235B-A22B-Instruct-2507-FP8",
    messages=[{"role": "user", "content": "Write a quicksort in Python."}],
) as stream:
    for text in stream.text_stream:
        print(text, end="", flush=True)

Aider

shell
aider --openai-api-base https://fair-price.ai/api/v1 \
      --openai-api-key fp-sk-your_key_here \
      --model Qwen/Qwen3-235B-A22B-Instruct-2507-FP8

Errors

Standard HTTP status codes. Error body follows OpenAI format.

StatusCauseFix
401Invalid or missing API keyCheck Authorization header
402Insufficient token balanceTop up at fair-price.ai/dashboard/topup
429Rate limit exceededSlow down requests or contact support
500Upstream inference errorRetry with exponential backoff
Error response body
{
  "error": {
    "message": "Insufficient token balance",
    "type": "insufficient_quota",
    "code": 402
  }
}

Pricing

Pre-purchase token bundles. No subscriptions. Tokens shared across all models.

Starter:$515M tokens
Pro:$2065M tokens
Scale:$50330M tokens

Crypto payments receive +10% bonus tokens. See all packages →