How to use the AshnaAI API in Claude Code
Install Claude Code CLI on macOS, Linux, or Windows, create an AshnaAI API key, point ANTHROPIC_BASE_URL at https://api.ashna.ai/v1/api, then run your first Messages turn.
AshnaAI

What you will set up
This guide walks through installing Claude Code CLI on your machine, creating one AshnaAI API key, pointing Claude Code at the AshnaAI Anthropic-compatible endpoint, and running your first turn. Official install docs: Claude Code quickstart. Cursor uses a different protocol — see How to use the AshnaAI API in Cursor.
Step 1: Install Claude Code CLI
Claude Code is Anthropic’s terminal agent. Install it once per machine, then route requests to AshnaAI with environment variables. The commands below match the official quickstart.
▸ curl -fsSL https://claude.ai/install.sh | bashirm https://claude.ai/install.ps1 | iex▸ curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd▸ claude --version- Open a terminal in the project folder you want to work in.
- Run the install command for your operating system.
- Confirm the install with claude --version.
- Set ANTHROPIC_BASE_URL and ANTHROPIC_API_KEY in Step 3 before your first turn.
Step 2: Create an AshnaAI API key
Do this once. Claude Code sends the secret on every request to AshnaAI.
- Open Account → API.
- Choose Create key and name it Claude Code.
- Copy the secret immediately. It is shown once.
- Keep it out of git, a gist, and a recorded screen.
Step 3: Point Claude Code at AshnaAI
Export both variables in the same shell that will launch Claude Code. Settings reference: Claude Code settings.
▸ export ANTHROPIC_BASE_URL="https://api.ashna.ai/v1/api"▸ export ANTHROPIC_API_KEY="paste-your-key-here"$env:ANTHROPIC_BASE_URL="https://api.ashna.ai/v1/api"//api.ashna.ai/v1/api"$env:ANTHROPIC_API_KEY="paste-your-key-here"▸ set ANTHROPIC_BASE_URL=https://api.ashna.ai/v1/api▸ set ANTHROPIC_API_KEY=paste-your-key-here- Confirm the base URL includes /v1/api. A host-only value is the usual 404.
- If your wrapper reads ANTHROPIC_AUTH_TOKEN instead, set that name to the same secret.
- Add the export lines to ~/.zshrc, ~/.bashrc, or your shell profile to persist them.
Step 4: Pick a model id
Use an alias or a catalog id. You do not change the URL.
- Set the model to sonnet, opus, haiku, or a catalog id when Claude Code asks.
- For Claude-style routing, choose sonnet, opus, or haiku.
- For a catalog model, type glm-5.3-flash or another listed id.
- To list ids from the API, run: curl -H "Authorization: Bearer YOUR_KEY" https://api.ashna.ai/v1/api/models
Step 5: Run your first Claude Code turn
Start the CLI from the shell that has the two environment variables.
▸ cd /path/to/your/project▸ claude- Send one prompt such as explain the folder structure.
- Claude Code posts to /v1/messages on api.ashna.ai.
- If the turn fails with 401, the key is missing or truncated. Repeat Step 2.
- If the turn fails with 404, the base URL dropped /v1/api. Repeat Step 3.
Fields that have to match
Paste these values. A typo on the base URL is the usual failure.
| Field | Value |
|---|---|
| Install (macOS/Linux) | curl -fsSL https://claude.ai/install.sh | bash |
| Install (Windows) | irm https://claude.ai/install.ps1 | iex |
| ANTHROPIC_BASE_URL | https://api.ashna.ai/v1/api |
| ANTHROPIC_API_KEY | Secret from Account → API |
| Messages path | /v1/messages |
| Example aliases | sonnet, opus, haiku |
Try it now
HTTP reference: AshnaAI API docs and chat completions for other clients.
- Install Claude Code with the command for your OS.
- Create a key in Account → API.
- Export ANTHROPIC_BASE_URL and ANTHROPIC_API_KEY, then run one turn.
Frequently asked questions
- How do I install Claude Code on macOS or Linux?
- Run curl -fsSL https://claude.ai/install.sh | bash from a terminal, then verify with claude --version. Full steps: https://code.claude.com/docs/en/quickstart
- How do I install Claude Code on Windows?
- In PowerShell run irm https://claude.ai/install.ps1 | iex, or in CMD use the install.cmd one-liner from the Claude Code quickstart. Then run claude --version.
- What ANTHROPIC_BASE_URL does Claude Code need for AshnaAI?
- https://api.ashna.ai/v1/api Claude Code then posts to /v1/messages on that host.
- Does Claude Code use Chat Completions?
- No. Claude Code is an Anthropic Messages client. Cursor and VS Code use Chat Completions instead.
- Which model aliases work?
- sonnet maps to claude-sonnet-5, opus to claude-opus-5, and haiku to claude-haiku-4.5. Dated Claude ids and catalog ids such as glm-5.3-flash also work.
Tags
Related
- AshnaAI for Work
- AshnaAI vs ChatGPT
- AshnaAI vs Claude
- Large Language Model (LLM)
- Foundation Model
- how to use the ashna ai api in cursor
- how to use the ashna ai api in vs code
- how to use the ashna ai api in openclaw cline and codex
- how to call any catalog model through the api
- ashna x1 task aware model routing
Try this in AshnaAI. Create a free account.
Found this article helpful? Share it with your network.