# Use with coding agents

Set up Claude Code, Cursor, Codex, or any coding agent to call the Anara API correctly on the first try.

Coding agents do best when they have a key in the environment, a short note on how the API works, and docs they can read as Markdown. This page gives you all three.

## 1. Put your key in the environment [#1-put-your-key-in-the-environment]

Create a key under [API keys](https://platform.anara.com/keys) in the console, then export it. Agents should read it from the environment and never paste it into code.

```bash title="Terminal"
export ANARA_API_KEY="ana_live_..."
```

## 2. Add the API to your agent instructions [#2-add-the-api-to-your-agent-instructions]

Paste this into `AGENTS.md` at the root of your repo (Codex, Cursor, and most agents read it; Claude Code reads `CLAUDE.md`, so put it there too, or import `AGENTS.md` from it).

```md title="AGENTS.md"
## Anara API (academic paper search)

- Base URL: https://api.anara.com. Auth: `Authorization: Bearer $ANARA_API_KEY`. Never hardcode the key.
- Search papers: `POST /v1/search` with `{"query": "...", "type": "standard", "maxResults": 10}`.
  `type` is `instant` (fastest), `standard` (default, hybrid), or `deep` (open-access full text with citable passages).
  Optional `filters`, for example `{"publicationYear": ">=2021", "hasFulltext": true}`.
- Resolve known papers: `POST /v1/resolve` with `{"identifiers": [...]}` (DOI, arXiv, OpenAlex, or PubMed ids)
  and/or `{"titles": [...]}`.
- Application errors are JSON with a `_tag` and a `message`; schema-invalid requests can return `400` with an empty body. `402 PaymentRequired` means the workspace needs credit.
- Docs as Markdown: https://docs.anara.com/api/llms.txt lists every API page; append `.md` to any docs URL.
- OpenAPI spec: https://api.anara.com/openapi.json
```

## 3. Let the agent read the docs [#3-let-the-agent-read-the-docs]

* [`/api/llms.txt`](/api/llms.txt) lists only the API pages, each as a Markdown link.
* Append `.md` to any page URL, for example `https://docs.anara.com/api/search.md`.
* The docs MCP server at `https://docs.anara.com/mcp` lets an agent search and read every page. See [Use these docs with AI](/guides/docs-for-ai) for the client config.

## 4. Generate a typed client (optional) [#4-generate-a-typed-client-optional]

If you want types instead of raw requests, generate a client from the spec. See [OpenAPI and SDKs](/api/openapi).

## Check it works [#check-it-works]

Ask your agent to run a small search and print the titles. If it gets `401`, the key is missing or revoked; if it gets `403`, inspect the error tag for scope, platform-access, or HIPAA restrictions. See [Statuses](/api/statuses) for everything else.
