/* 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-demotoken1234567890Chat 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
| Status | Meaning | Behavior |
|---|---|---|
| 429 | Upstream throttled | Auto-retry on next key in pool |
| 502 | Upstream unhealthy | Route to fallback region |
| 402 | Balance depleted | No retry — top up |
| 400 | Invalid request | No 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.

