---
name: agentsky-api-setup
description: Connect this computer's AI tools to the AgentSky API with the person's AgentSky API key. Use when they paste a message pointing here.
---

# Connect this computer to the AgentSky API

You are setting up the person's own tools to call Claude, GPT, DeepSeek and other models through AgentSky. Work in their user-level config, change only what this guide names, and keep a backup of any file you edit.

## 1. Get the key from the person

- The key starts with `ast_`. Ask them to paste it. Do not print it back, log it, or write it into a project or git repository.
- No key yet: send them to https://agentsky.dev/gateway/buy (or the invitation link they were given). After sign-up the key is shown on https://platform.agentsky.dev/gateway/start.
- Calls need credit. If they have not added any, ask them to click **Add credit** on https://platform.agentsky.dev/gateway/start first.

## 2. Check the key with one call

Put the key in this shell session only (`export AGENTSKY_API_KEY=...` without echoing it), then run:

```bash
curl -s https://gateway.agentsky.dev/v1/messages \
  -H "Authorization: Bearer $AGENTSKY_API_KEY" \
  -H "anthropic-version: 2023-06-01" -H "Content-Type: application/json" \
  -d '{"model": "claude-haiku-5-5", "max_tokens": 16, "messages": [{"role": "user", "content": "Reply with exactly: pong"}]}'
```

Expect HTTP 200 and `usage.cost` in the reply. Otherwise:

| Reply | Meaning | Do |
|---|---|---|
| 401 | Key wrong or revoked | Ask them to copy the key again from https://platform.agentsky.dev/gateway/start |
| Error about credit or balance | No credit | Ask them to click Add credit on https://platform.agentsky.dev/gateway/start |
| 404 `model_not_found` | Model sent to the wrong format | See section 3 |
| 503 "model has no price" | That model is not sellable right now | Pick another model |

## 3. Values every tool needs

- Anthropic format (Claude models, `POST /v1/messages`): base URL `https://gateway.agentsky.dev`
- OpenAI format (GPT, DeepSeek, Kimi, GLM, Qwen, Gemini and the rest, `POST /v1/chat/completions` and `POST /v1/responses`): base URL `https://gateway.agentsky.dev/v1`
- The key goes in `Authorization: Bearer` on both; the Anthropic route also accepts `x-api-key`.
- Model IDs: `GET https://gateway.agentsky.dev/v1/models`. Each entry's `wires` says which format it speaks. Claude IDs also work without the `anthropic/` prefix (`claude-sonnet-5-5`). Claude is not served on the OpenAI format.

## 4. Configure the tools they use

Ask which of these they use (or check which are installed) and set up only those.

### Claude Code
Merge into `~/.claude/settings.json` (create it if missing; keep every other key):
```json
{ "env": { "ANTHROPIC_BASE_URL": "https://gateway.agentsky.dev", "ANTHROPIC_AUTH_TOKEN": "<their key>" } }
```
Verify: `claude -p "Reply with exactly: pong"` prints `pong`. In an interactive session `/status` shows the base URL. If `ANTHROPIC_API_KEY` is exported in their shell, tell them it can override this.

### Codex CLI
Add to `~/.codex/config.toml`:
```toml
[model_providers.agentsky]
name = "AgentSky"
base_url = "https://gateway.agentsky.dev/v1"
env_key = "AGENTSKY_API_KEY"
wire_api = "responses"
```
Create `~/.codex/agentsky.config.toml`:
```toml
model = "openai/gpt-6.1-sol"
model_provider = "agentsky"
```
Put `AGENTSKY_API_KEY=<their key>` in `~/.codex/.env` or their shell profile. Their default Codex setup is unchanged; they use AgentSky with `codex --profile agentsky`.
Verify: `codex exec --profile agentsky --skip-git-repo-check "Reply with exactly: pong" < /dev/null` ends with `pong`.

### Code using the OpenAI or Anthropic SDK
Set in their shell profile or the project's untracked `.env`:
```bash
OPENAI_BASE_URL=https://gateway.agentsky.dev/v1
OPENAI_API_KEY=<their key>
ANTHROPIC_BASE_URL=https://gateway.agentsky.dev
ANTHROPIC_API_KEY=<their key>
```

### Apps with a settings screen (Cursor, Cherry Studio, Chatbox and similar)
You cannot fill these in. Tell the person exactly what to paste: an OpenAI-compatible provider with base URL `https://gateway.agentsky.dev/v1`; for Claude, an Anthropic provider with base URL `https://gateway.agentsky.dev`; their key as the API key; a model ID from section 3.

## 5. Finish

Run the verify step for every tool you configured, then report in a few lines: what you changed (file paths), what each test returned, and anything the person still has to do. Do not show the key.

Full API reference: https://agentsky.dev/docs/gateway
