/* documentation */

Forge Gateway API

The Forge Gateway is a drop-in replacement for the OpenAI HTTP API. Any client that speaks /v1/chat/completions works — Python, Node, Go, curl, LangChain, LlamaIndex, Vercel AI SDK.

Quickstart

Install the OpenAI SDK and point it at Forge.

bash
pip install openai
export FORGE_API_KEY=fg-...
python
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["FORGE_API_KEY"],
    base_url="https://forge-gateway-api.fly.dev/v1",
)

r = client.chat.completions.create(
    model="claude-sonnet-4-5",
    messages=[{"role": "user", "content": "hello"}],
)
print(r.choices[0].message.content)

Authentication

Every request uses a bearer token created under API Keys. Keys are scoped per project.

http
Authorization: Bearer fg-demotoken1234567890

Chat completions

Full parity with the OpenAI schema — messages, tools, response_format, temperature, top_p, and reasoning_effort where supported.

curl
curl https://forge-gateway-api.fly.dev/v1/chat/completions \
  -H "Authorization: Bearer $FORGE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-r1",
    "messages": [{"role": "user", "content": "Ping"}]
  }'

Streaming

Set stream: true to receive server-sent events. Forge terminates and re-emits SSE at the edge for stable connections.

Errors & retries

StatusMeaningBehavior
429Upstream throttledAuto-retry on next key in pool
502Upstream unhealthyRoute to fallback region
402Balance depletedNo retry — top up
400Invalid requestNo retry — client error

Rate limits

Free tier: 60 RPM · Pro: 1,000 RPM. Limits are enforced per key. Each response includes x-forge-remaining and x-forge-reset.