# AI agents

These docs are built to be read by machines as easily as by people. An agent should never have to guess: there is a map, a full copy, a Markdown version of every page and a machine-readable API description.

## What to give your agent

| Resource | URL | Use it for |
| --- | --- | --- |
| Index | [`https://onekey.dev/llms.txt`](https://onekey.dev/llms.txt) | A short map of the docs with links. Start here. |
| Everything | [`https://onekey.dev/llms-full.txt`](https://onekey.dev/llms-full.txt) | The whole docs, every endpoint, in one file. Paste or attach this if the agent cannot browse. |
| One page | `/docs/<page>.md` | Any page as clean Markdown, e.g. [`/docs/quickstart.md`](https://onekey.dev/docs/quickstart.md). |
| One endpoint | `/docs/api/<platform>/<endpoint>.md` | Everything about a single endpoint. |
| OpenAPI | [`/openapi.json`](https://onekey.dev/openapi.json) | Generate clients, or let tools import every endpoint. |
| Live catalog | `GET https://api.onekey.dev/v1/platforms` | Current endpoints, prices and parameters. No key, no cost. |

On every docs page, **Copy page for AI** copies its Markdown and **View as Markdown** opens the raw text.

## Point your tool at Onekey

- **Claude (chat or Claude Code):** paste the system prompt below, or just say "read https://onekey.dev/llms.txt and use it to call the Onekey API".
- **Cursor:** add `https://onekey.dev/llms-full.txt` as a documentation source (Settings, then Indexing & Docs), and put the system prompt in a project rule.
- **ChatGPT and others:** attach `llms-full.txt`, or paste the prompt and give the model your key through your tool's secret handling.
- **Anything with HTTP:** import `/openapi.json`.
- **MCP clients (Claude Code, Claude Desktop, Cursor):** connect the hosted [MCP server](https://onekey.dev/docs/mcp.md) with your key, and the agent gets eleven tools to find and call endpoints, including [universal search](https://onekey.dev/docs/universal-search.md) and the [reports](https://onekey.dev/docs/reports.md). Step-by-step guides for [n8n, LangChain, the Vercel AI SDK and Claude Code](https://onekey.dev/docs/integrations.md) are on their own pages.

> [!WARN] Give the agent your key through an environment variable or your tool's secret store, not by pasting it into a chat.

## A ready-to-paste system prompt

```text
You can call the Onekey API for public data from many platforms.

Base URL: https://api.onekey.dev
Auth: send header "x-api-key" with the key from the environment variable ONEKEY_KEY. Never print or log the key.
Call shape: GET /v1/{platform}/{endpoint}?{params}
Discover endpoints (free, no key): GET /v1/platforms. Read parameter names from it; do not guess them.
Docs index: https://onekey.dev/llms.txt. Full docs: https://onekey.dev/llms-full.txt.

Rules:
1. Every response is {success, data, metadata, error}. Check "success" before using "data".
2. Branch on error.code, not error.message. Never retry 400, 401, 402, 404, 405 or 422.
3. Retry 429 after the Retry-After seconds, and retry 500/502 with exponential backoff (max 4 tries).
4. Each endpoint costs a flat number of credits (metadata.credits_charged). Cache hits are free. Do not repeat identical calls in a loop.
5. If metadata.stale is true the data is a little old; say so if freshness matters.
6. A 402 means the account is out of credits: stop and tell the user.
```

## Why it is agent friendly

- One shape for every platform, so an agent's parsing code does not change between sources.
- Errors have stable codes and clear retry guidance.
- Costs are flat and printed on every endpoint page and in every response.
- Free discovery: `/v1/platforms` and `/v1/account` cost nothing.
- One query in words, or a report on a brand, a creator or a topic: an agent can call [universal search](https://onekey.dev/docs/universal-search.md) or a [report](https://onekey.dev/docs/reports.md) instead of assembling the calls itself. Both report what they did and what each part cost.
- Agents that should react to change do not have to poll: a [monitor](https://onekey.dev/docs/monitors.md) calls your webhook when the data moves.
