FROM ZERO TO FIRST REQUEST

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. 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. 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. 3

    Send a request

    Replace YOUR_MODEL_ID with an ID from Models & pricing. Store your key in EARTH_API_KEY. Models & pricing

Terminal
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.

MethodEndpointUse for
GET/v1/modelsAvailable model IDs
POST/v1/responsesResponses requests
POST/v1/chat/completionsChat Completions clients
POST/v1/messagesAnthropic 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.

Terminal
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.

app.ts
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 ?? "");
}
A model request is sent once. If a connection drops, check your usage before sending it again.

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

Terminal
curl https://api.earth.icu/api/keys \
  -H "Authorization: Bearer $EARTH_MANAGEMENT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name":"Production app"}'
MethodEndpointAction
GET / POST/api/keysList / create keys
PATCH/api/keys/:idUpdate name or enabled state
POST/api/keys/:id/revealView the full key again
DELETE/api/keys/:idRevoke a key
GET/api/usageView 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.

StatusWhat to check
400Check the model ID, request format, and supported options.
401 / 403Verify your key is correct, enabled, and has not expired.
402Add funds to your OGS account balance.
429The provider is rate limiting this model (error.source is upstream). Retry after the Retry-After interval when one is sent.
500 / 502 / 504 / 529The provider failed, was overloaded (529) or timed out before any output (error.source is upstream). Try again later.
503With 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.

Open console