API Reference

OpenAI-compatible. Point any official SDK at the base URL below and use your TokenForge key.

Base URL  https://api.tokenforge.dev/v1
Auth      Authorization: Bearer sk-live-...

Quickstart

from openai import OpenAI

client = OpenAI(
    base_url="https://api.tokenforge.dev/v1",
    api_key="sk-live-...",
)

stream = client.chat.completions.create(
    model="deepseek-chat",
    messages=[{"role": "user", "content": "Explain vector search in 2 sentences."}],
    stream=True,
)
for chunk in stream:
    print(chunk.choices[0].delta.content or "", end="")

POST /v1/chat/completions

FieldTypeDescription
modelstringRequired. One of the ids listed below.
messagesarrayRequired. OpenAI message objects (role, content).
streambooleanStream tokens as server-sent events.
max_tokensintegerUpper bound on output tokens. Clamped to the model maximum.
temperaturenumber0–2. Passed through to the provider.
tools / tool_choicearrayFunction calling, where the model supports it.
response_formatobjectjson_object mode, where supported.

GET /v1/models

Returns every model available to your account, with context length and per-million pricing.

ModelContextMax output
deepseek-chat1,000,000384,000
deepseek-reasoner1,000,000384,000
qwen-plus131,0728,192

Errors

StatusCodeMeaning
400invalid_request_errorMalformed JSON, missing messages, or max_tokens out of range.
401authentication_errorMissing or invalid API key.
402insufficient_quotaBalance is empty or the key spend cap is reached.
403permission_errorKey not permitted for this model, or account suspended.
404model_not_foundUnknown model id. Call GET /v1/models for the current list.
429rate_limit_errorPer-key RPM or TPM exceeded. Respect Retry-After.
502upstream_errorAll upstream channels for this model failed. Safe to retry.

Rate limits

Limits apply per key. Default is 60 requests per minute; higher limits on request. Responses include Retry-After on 429. Token-per-minute limits follow upstream capacity and scale with your account tier.

Streaming

Set stream: true to receive server-sent events. Chunks follow the OpenAI format and terminate with data: [DONE]. Usage is reported in the final chunk and is what your balance is charged against.