Build with Earth API.
One endpoint for OpenAI and Anthropic models. Start with an API key and a model from the live catalog.
Quickstart
- 1
Sign in with OGS
Sign in to the console with your Earth account. Add funds to your shared balance through the account menu. Open console
- 2
Create an API key
Create a key in API keys, give it a name, and copy it. Keep it on your server, never in a public browser app. API keys
- 3
Send a request
Replace YOUR_MODEL_ID with an ID from Models & pricing. Store your key in EARTH_API_KEY. Models & pricing
curl https://api.earth.icu/v1/chat/completions \
-H "Authorization: Bearer $EARTH_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "YOUR_MODEL_ID",
"messages": [{"role": "user", "content": "Hello!"}]
}'Choose your endpoint
Provider-native endpoints preserve the provider’s request format. The Chat and Responses adapters support common text and tool workflows; unsupported options return an explicit error.
| Method | Endpoint | Use for |
|---|---|---|
| GET | /v1/models | Available model IDs |
| POST | /v1/responses | Responses requests |
| POST | /v1/chat/completions | Chat Completions clients |
| POST | /v1/messages | Anthropic Messages requests |
Anthropic Messages
Use an available Anthropic model and include the output token budget. The x-api-key header accepts your Earth API key.
curl https://api.earth.icu/v1/messages \
-H "x-api-key: $EARTH_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "YOUR_ANTHROPIC_MODEL_ID",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Hello!"}]
}'Stream responses
Set stream: true to receive server-sent events. Keep the connection open until the stream ends to receive the complete response.
const stream = await client.chat.completions.create({
model: "YOUR_MODEL_ID",
messages: [{ role: "user", content: "Hello!" }],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}Understand your bill
Every API key belongs to your OGS account and uses that account’s balance. Requests are charged using the actual token usage reported by the upstream and the model price saved when the request starts.
- Input, cached input, cache writes, and output have separate rates.
- Cache reads and writes are billed in their own categories, without charging the same tokens again as regular input.
- A positive balance is required to start a request. Concurrent requests already running can finish with a negative balance.
- If final usage is unavailable, the request remains pending for reconciliation. Token counts are never guessed.
View costs and request status in Usage. Add funds using the OGS account menu. Usage
Manage keys with an API
Create a management token in Settings to automate key creation and updates for your account. A management token is separate from a model API key. Settings
curl https://api.earth.icu/api/keys \
-H "Authorization: Bearer $EARTH_MANAGEMENT_TOKEN" \
-H "Content-Type: application/json" \
-d '{"name":"Production app"}'| Method | Endpoint | Action |
|---|---|---|
| GET / POST | /api/keys | List / create keys |
| PATCH | /api/keys/:id | Update name or enabled state |
| POST | /api/keys/:id/reveal | View the full key again |
| DELETE | /api/keys/:id | Revoke a key |
| GET | /api/usage | View recent usage |
When a request fails
Errors include a readable error.message and machine-readable error.code. Keep the request ID when contacting support or reviewing a request.
| Status | What to check |
|---|---|
| 400 | Check the model ID, request format, and supported options. |
| 401 / 403 | Verify your key is correct, enabled, and has not expired. |
| 402 | Add funds to your OGS account balance. |
| 429 | The provider is rate limiting this model (error.source is upstream). Retry after the Retry-After interval when one is sent. |
| 500 / 502 / 504 / 529 | The provider failed, was overloaded (529) or timed out before any output (error.source is upstream). Try again later. |
| 503 | With error.source platform, no eligible account could take the request: busy, cooling down, at its quota limit, awaiting credentials or disabled. When accounts were busy or about to recover, Earth API first waited for a free slot. Retry after the Retry-After interval when one is sent. |
You’re ready to build.
Your workspace is one sign-in away.