All skills

Gatelum API basics

Connect an agent to Gatelum: base URL, key, model discovery, OpenAI and Anthropic calls, balance and error codes.

Author
Gatelum
License
CC-BY-4.0
Section
Gatelum

Source at the pinned commit

SKILL.md content

---
name: gatelum-api
description: Use the Gatelum gateway correctly - base URL, key, model discovery, OpenAI and Anthropic request formats, balance checks, and the error codes that explain a refusal.
license: CC-BY-4.0
---

# Gatelum API

Use this skill whenever a task needs a language or multimodal model through Gatelum.
Gatelum exposes one OpenAI-compatible gateway for models from OpenAI, Anthropic,
Google, DeepSeek, xAI and other providers. One key and one base URL reach all of them.

## Connection

| Setting | Value |
| --- | --- |
| Base URL | `https://api.gatelum.com/v1` |
| Key variable | `GATELUM_API_KEY` |
| OpenAI-style header | `Authorization: Bearer $GATELUM_API_KEY` |
| Anthropic-style header | `x-api-key: $GATELUM_API_KEY` |

Read the key from the environment. Never hard-code it, print it, or write it into a
repository file. If the variable is missing, ask the user for it instead of guessing.

## Discover models before calling one

Do not guess model ids. Fetch the catalog first:

```bash
curl -s https://api.gatelum.com/v1/models \
  -H "Authorization: Bearer $GATELUM_API_KEY"
```

Choose an `id` from the response. When a request fails with `model_not_found`,
fetch the list again and pick an id that is present.

## OpenAI-compatible request

```bash
curl -s https://api.gatelum.com/v1/chat/completions \
  -H "Authorization: Bearer $GATELUM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"<id from /v1/models>","messages":[{"role":"user","content":"Hello"}]}'
```

The OpenAI SDK needs only two changes:

```python
from openai import OpenAI

client = OpenAI(
    base_url="https://api.gatelum.com/v1",
    api_key=os.environ["GATELUM_API_KEY"],
)
```

## Anthropic-compatible request

Models that expose the Anthropic Messages shape accept `POST /v1/messages`:

```bash
curl -s https://api.gatelum.com/v1/messages \
  -H "x-api-key: $GATELUM_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{"model":"<id from /v1/models>","max_tokens":1024,"messages":[{"role":"user","content":"Hello"}]}'
```

Use the native SDK when it fits the task; otherwise the OpenAI-compatible endpoint
reaches the same catalog.

## Check the balance

`GET /v1/workspace` returns the account balance and the key's spend for the current
window. Call it before a long job and after a `balance_depleted` refusal. The balance
lives in `balance.available_usd`; history is available with `?window=7d`.

The balance is not a separate endpoint: read it from the workspace summary.

## Error codes

Read `error.code` from the JSON body. Retry only transient codes; fix the request for
the rest.

| Status | Code | What to do |
| --- | --- | --- |
| 400 | `bad_request` | Fix the JSON body or an unsupported parameter. |
| 401 | `invalid_api_key` | Check `GATELUM_API_KEY`; ask the user for a valid key. |
| 402 | `balance_depleted` | Stop and report that the account balance is exhausted. |
| 403 | `permission_denied` | The key is outside its allowed hours or scope; report it. |
| 404 | `model_not_found` | Refresh `/v1/models` and choose an available id. |
| 408 | `timeout` | Retry once with a smaller request. |
| 413 | `body_too_large` | Send less data per request. |
| 429 | `insufficient_quota` | The key hit its spending cap; report it. |
| 429 | `too_many_requests` | Back off and retry with jitter. |
| 500 | `server_fault` | Retry once; if it repeats, report the trace id. |
| 502 | `provider_error` | The upstream provider failed; retry later. |

## Report back

When the work is done, state which model id was used, what the request cost in tokens
from the response `usage`, and any error code that changed the plan. Do not paste the
API key or the full prompt into the report.

Install this skill

Claude Code

bash
mkdir -p ~/.claude/skills && curl -fsSL "https://gatelum.com/skills/gatelum/gatelum-api.tar.gz" | tar -xz -C ~/.claude/skills
PowerShell
New-Item -ItemType Directory -Force -Path "$env:USERPROFILE\.claude\skills" | Out-Null; $tmp = Join-Path $env:TEMP "gatelum-api.tar.gz"; curl.exe -fsSL "https://gatelum.com/skills/gatelum/gatelum-api.tar.gz" -o $tmp; tar.exe -xzf $tmp -C "$env:USERPROFILE\.claude\skills"; Remove-Item -Force $tmp

Codex & Cursor

bash
mkdir -p ~/.agents/skills && curl -fsSL "https://gatelum.com/skills/gatelum/gatelum-api.tar.gz" | tar -xz -C ~/.agents/skills
PowerShell
New-Item -ItemType Directory -Force -Path "$env:USERPROFILE\.agents\skills" | Out-Null; $tmp = Join-Path $env:TEMP "gatelum-api.tar.gz"; curl.exe -fsSL "https://gatelum.com/skills/gatelum/gatelum-api.tar.gz" -o $tmp; tar.exe -xzf $tmp -C "$env:USERPROFILE\.agents\skills"; Remove-Item -Force $tmp