Cursor
How to use the AshnaAI API in Cursor
Install Cursor or the Cursor CLI, paste an Account → API key, and set Override OpenAI Base URL to https://api.ashna.ai/v1/api.
Read the guideThe AshnaAI HTTP API speaks three client protocols on one host: OpenAI Chat Completions, Anthropic Messages (Claude Code), and OpenAI Responses (Codex). Use the same Account → API key. Point the client at https://api.ashna.ai/v1/api and set model to a foundation model id or your Ashna custom agent id.
Use this as baseURL, OPENAI_BASE_URL, or ANTHROPIC_BASE_URL. Clients append their own path: /chat/completions, /v1/messages, or /responses.
https://api.ashna.ai/v1/apiPOST /chat/completions
POST /v1/messages
POST /responses
Authorization: Bearer <your_key>. Claude Code also accepts x-api-key: <your_key>.Three request shapes on the same host. Chat Completions is verified with ai + @ai-sdk/openai. Claude Code posts Anthropic Messages. Codex posts OpenAI Responses.
POST /chat/completions (Cursor, VS Code, Cline, Continue, SDKs)POST /v1/messages (Claude Code)POST /responses (Codex)model (for example glm-5.3, claude-sonnet-5, claude-opus-5, claude-fable-5, gpt-4o-mini, Ashna models)model or agent_id (server-side multi-step tools)tools / tool_choice) with tool_calls round-tripstemperature, top_p / top_k, penalties, stop, seed, max_tokens / max_completion_tokensresponse_format json_object and json_schema[DONE], usage, tool call deltas)streamType: "data"{ error: { message, type, code, param } }GET /models catalogCreate a key, then call Chat Completions with an OpenAI-compatible client — or point Claude Code at the same host with ANTHROPIC_BASE_URL.
Open Account → API on app.ashna.ai and create a key.
Set model to a foundation model id or your custom agent id from the Ashna app. Use the examples on the right.
import { createOpenAI } from '@ai-sdk/openai';import { generateText } from 'ai'; const ashnaAI = createOpenAI({ baseURL: 'https://api.ashna.ai/v1/api'//api.ashna.ai/v1/api', apiKey: process.env.ASHNA_API_KEY,}); const { text } = await generateText({ model: ashnaAI.chat("gpt-4o-mini"), messages: [ { role: 'user', content: "Hello, can you help me?" } ], maxOutputTokens: 500, temperature: 0.7,}); console.log(text);Chat Completions uses a single model field. Pass either a foundation model id or your custom agent id. You can also send agent_id when model is omitted.
A catalog id for a built-in Ashna / provider model (for example glm-5.3, claude-sonnet-5, claude-opus-5, claude-fable-5, ashna-x1). Use this when you want a raw model without your custom agent prompt/tools.
Where to find it:
GET /v1/api/modelsYour Ashna agent's customAgentId (slug). When you pass this as model, Ashna loads that agent's system prompt, tools, and data sources and runs them server-side.
Where to find it:
?agent=<customAgentId>Example: { "model": "my-support-agent-8k2qv" } or { "agent_id": "my-support-agent-8k2qv" }.
Use any of these values as model for foundation-model Chat Completions. Grouped by provider family (OpenAI, Anthropic, DeepSeek, Google, and others).
Showing 69 of 69 supported model ids, grouped by provider.
claude-fable-5claude-haiku-4.5claude-opus-4.1claude-opus-4.5claude-opus-5claude-sonnet-4.5claude-sonnet-5ashna-diffusion-1ashna-x1deepseek-v4-flashdeepseek-v4-prodeepseek-v4.1-flashglm-4.7glm-5glm-5.1glm-5.2glm-5.3glm-5.3-flashgemini-2.0-flashgemini-2.5-Flashgemini-2.5-Flash-Litegemini-2.5-Progemini-3-Flash-Previewgemini-3-Progemini-3.1-Flash-Litegemini-3.1-Progemini-3.5-Flashinklingkimi-2.6kimi-k2-thinkingkimi-k2.5-thinkingkimi-k2.7-codekimi-k3llama-3.3 70Bllama-4-scoutmistral-3b-latestmistral-large-3mistral-open-8.22Bnemotron-ultragpt-3.5-turbogpt-4.1gpt-4.1-minigpt-4.1-nanogpt-4ogpt-4o-minigpt-5gpt-5-codexgpt-5-minigpt-5.1gpt-5.1-codexgpt-5.2gpt-5.2-codexgpt-5.2-thinkinggpt-5.3-codexgpt-5.4gpt-5.4-thinkinggpt-5.5gpt-5.6-lunagpt-5.6-solgpt-5.6-terragpt-6-astragpt-o1gpt-o3-minigpt-o4-minigpt-oss-120bgpt-oss-20bgrok-4-1-non-reasoninggrok-4-reasoninggrok-4.3All requests need the key from Account → API. OpenAI-compatible clients send a Bearer token. Claude Code sends the same secret as ANTHROPIC_API_KEY / x-api-key.
AuthorizationstringBearer YOUR_API_KEY — Chat Completions, Responses, and GET /models
x-api-keystringSame secret. Claude Code and other Anthropic Messages clients send this header.
Content-Typestringapplication/json for POST bodies
▸ curl https://api.ashna.ai/v1/api/models \▸ -H "Authorization: Bearer YOUR_API_KEY"▸ curl https://api.ashna.ai/v1/api/v1/messages \▸ -H "x-api-key: YOUR_API_KEY" \▸ -H "anthropic-version: 2023-06-01" \▸ -H "Content-Type: application/json"Paste a key from Account → API, choose a model or agent id, and send a live Chat Completions request. Your key stays in this browser tab only.
Send a request to see the assistant reply and OpenAI-compatible JSON here.
Failures return an OpenAI-compatible envelope so SDKs can surface error.message consistently.
400Invalid JSON, empty messages, or invalid params
401Missing or invalid API key
403Model / entitlement not allowed for this key
404Unknown model or agent id
429Too many requests
500Unexpected failure while processing the request
{ "error": { "message": "Invalid API key provided.", "type": "invalid_request_error", "code": "invalid_api_key", "param": null }}Primary integration path is OpenAI Chat Completions. Paths below are relative to https://api.ashna.ai/v1/api.
Returns foundation models available through the external API (OpenAI { object: "list", data } shape). Custom agents are not listed here—use your agent's customAgentId directly as model (see Model & agent IDs).
/v1/api/models▸ curl https://api.ashna.ai/v1/api/models \▸ -H "Authorization: Bearer YOUR_API_KEY"{ "object": "list", "data": [ { "id": "gpt-4o-mini", "object": "model", "created": 1704369000, "owned_by": "openai" } ]}Stateless OpenAI-compatible chat endpoint. Works with the OpenAI SDKs, Vercel AI SDK (generateText / streamText), Cursor, VS Code, Cline, and Continue. Claude Code does not use this path — it posts Anthropic Messages.
/v1/api/chat/completionsmodelstringFoundation model id or Ashna custom agent id. Alias: agent_id when model is omitted.
messagesarrayOpenAI messages (system, user, assistant, tool). Also accepts input or a string prompt.
systemstringOptional top-level system instructions (merged with message-role system content).
streambooleantrue → OpenAI SSE chunks ending with [DONE]. Omit / false → JSON chat.completion.
streamType"text" | "data"Default text (OpenAI SSE). Use data for Ashna UI-message data streams (agent tool progress). Not OpenAI chunk format.
max_tokensnumberMax output tokens. Also: max_completion_tokens, maxTokens, maxOutputTokens.
import { createOpenAI } from '@ai-sdk/openai';import { generateText } from 'ai'; const ashnaAI = createOpenAI({ baseURL: 'https://api.ashna.ai/v1/api'//api.ashna.ai/v1/api', apiKey: process.env.ASHNA_API_KEY,}); const { text } = await generateText({ model: ashnaAI.chat("gpt-4o-mini"), messages: [ { role: 'system', content: "You are a helpful assistant." }, { role: 'user', content: "Explain quantum computing briefly." } ], maxOutputTokens: 500, temperature: 0.7,}); console.log(text);{ "id": "chatcmpl-abc123", "object": "chat.completion", "created": 1704369000, "model": "gpt-4o-mini", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "Quantum computing leverages quantum mechanics..." }, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 25, "completion_tokens": 120, "total_tokens": 145 }}Anthropic Messages–compatible endpoint. Claude Code posts here — not Chat Completions. Set ANTHROPIC_BASE_URL to https://api.ashna.ai/v1/api so the CLI posts /v1/messages on that host. Use aliases sonnet, opus, haiku, or a catalog id such as glm-5.3-flash. Step-by-step install and first turn: How to use the AshnaAI API in Claude Code.
/v1/api/v1/messagesANTHROPIC_BASE_URLenvhttps://api.ashna.ai/v1/api. Do not drop /v1/api.
ANTHROPIC_API_KEYenvThe same secret from Account → API. Claude Code sends it as x-api-key.
modelstringsonnet, opus, haiku, a dated Claude id, or any catalog / custom agent id.
messagesarrayAnthropic Messages array. Claude Code builds this for each turn.
max_tokensnumberRequired on raw HTTP calls. Claude Code sets this itself.
▸ export ANTHROPIC_BASE_URL="https://api.ashna.ai/v1/api"▸ export ANTHROPIC_API_KEY="YOUR_API_KEY"▸ cd /path/to/your/project▸ claude▸ curl https://api.ashna.ai/v1/api/v1/messages \▸ -H "x-api-key: YOUR_API_KEY" \▸ -H "anthropic-version: 2023-06-01" \▸ -H "Content-Type: application/json" \▸ -d '{▸ "model": "sonnet",▸ "max_tokens": 256,▸ "messages": [▸ { "role": "user", "content": "Reply with exactly: ping" }▸ ]▸ }'{ "id": "msg_abc123", "type": "message", "role": "assistant", "model": "sonnet", "content": [ { "type": "text", "text": "ping" } ], "stop_reason": "end_turn", "usage": { "input_tokens": 12, "output_tokens": 1 }}OpenAI Responses–compatible endpoint. Codex CLI posts here — not Chat Completions. Set OPENAI_BASE_URL to https://api.ashna.ai/v1/api. OpenClaw can use the same path in openai-responses mode. Install and first turn: How to use the AshnaAI API in OpenClaw, Cline, and Codex.
/v1/api/responsesOPENAI_BASE_URLenvhttps://api.ashna.ai/v1/api
OPENAI_API_KEYenvBearer secret from Account → API.
modelstringCatalog id such as glm-5.3-flash or a custom agent id.
inputstring | arrayResponses input. Codex builds this for each turn.
▸ export OPENAI_BASE_URL="https://api.ashna.ai/v1/api"▸ export OPENAI_API_KEY="YOUR_API_KEY"▸ cd /path/to/your/project▸ codex▸ curl https://api.ashna.ai/v1/api/responses \▸ -H "Authorization: Bearer YOUR_API_KEY" \▸ -H "Content-Type: application/json" \▸ -d '{▸ "model": "glm-5.3-flash",▸ "input": "Reply with exactly: ping"▸ }'Pass your Ashna custom agent id as model (or agent_id). The API loads that agent's prompt, foundation model, data sources, and tools, then runs a multi-step tool loop on the server (up to 200 steps)—similar to the Ashna web agent.
modelstringYour custom agent id from the Ashna app (for example my-agent-abc12).
agent_idstringAlias used when model is omitted.
stream: true (and default streamType: "text"), you receive OpenAI text SSE. Agent tools execute server-side; intermediate tool I/O is not forwarded as OpenAI chunks—only assistant text (and usage).stream: true and streamType: "data" to receive the Ashna UI-message data stream (tool progress). This is not OpenAI Chat Completions SSE—use an Ashna/AI SDK UI stream consumer, not a plain OpenAI SSE parser.import { createOpenAI } from '@ai-sdk/openai';import { generateText } from 'ai'; const ashnaAI = createOpenAI({ baseURL: 'https://api.ashna.ai/v1/api'//api.ashna.ai/v1/api', apiKey: process.env.ASHNA_API_KEY,}); const { text } = await generateText({ model: ashnaAI.chat("your-custom-agent-id"), messages: [ { role: 'user', content: "Summarize today's priorities." } ], maxOutputTokens: 400, temperature: 0.7,}); console.log(text);▸ curl https://api.ashna.ai/v1/api/chat/completions \▸ -H "Authorization: Bearer YOUR_API_KEY" \▸ -H "Content-Type: application/json" \▸ -d '{▸ "agent_id": "your-custom-agent-id",▸ "messages": [▸ { "role": "user", "content": "Hello" }▸ ]▸ }'Two modes:
tools / tool_choice on a foundation model. The API returns tool_calls (no server execute). You run the tool locally and send a follow-up with role: "tool" messages.model is a custom agent, configured tools run on the server across multiple steps.import { createOpenAI } from '@ai-sdk/openai';import { generateText, jsonSchema, tool } from 'ai'; const ashnaAI = createOpenAI({ baseURL: 'https://api.ashna.ai/v1/api'//api.ashna.ai/v1/api', apiKey: process.env.ASHNA_API_KEY,}); const weather = tool({ description: 'Get weather for a city', inputSchema: jsonSchema({ type: 'object', properties: { city: { type: 'string' } }, required: ['city'], }), execute: async ({ city }) => ({ city, tempC: 21 }),}); const first = await generateText({ model: ashnaAI.chat('gpt-4o-mini'), tools: { get_weather: weather }, toolChoice: 'required', prompt: 'What is the weather in Paris? Use the tool.',}); // first.toolCalls → execute locally → send tool results back in messagestemperaturenumberSampling temperature. Some reasoning models reject non-default values; the API omits unsupported params automatically.
top_p / top_knumberNucleus / top-k sampling (aliases topP, topK).
frequency_penalty / presence_penaltynumberOpenAI-style penalties (camelCase aliases accepted).
stopstring | string[]Stop sequences.
seednumberBest-effort deterministic sampling when the provider supports it.
response_formatobject{ type: "json_object" } or { type: "json_schema", json_schema: { name, schema, ... } }.
json_object
import OpenAI from 'openai'; const client = new OpenAI({ apiKey: process.env.ASHNA_API_KEY, baseURL: 'https://api.ashna.ai/v1/api'//api.ashna.ai/v1/api',}); const response = await client.chat.completions.create({ model: "gpt-4o-mini", messages: [ { role: 'user', content: "Return JSON with keys a=1 and b=\"x\"." } ], temperature: 0.2, max_tokens: 80, response_format: {"type":"json_object"},}); console.log(response.choices[0].message.content);json_schema
▸ curl https://api.ashna.ai/v1/api/chat/completions \▸ -H "Authorization: Bearer YOUR_API_KEY" \▸ -H "Content-Type: application/json" \▸ -d '{▸ "model": "gpt-4o-mini",▸ "messages": [▸ {▸ "role": "user",▸ "content": "Return a city weather sample."▸ }▸ ],▸ "temperature": 0.2,▸ "max_tokens": 120,▸ "response_format": {▸ "type": "json_schema",▸ "json_schema": {▸ "name": "weather_sample",▸ "schema": {▸ "type": "object",▸ "additionalProperties": false,▸ "properties": {▸ "city": {▸ "type": "string"▸ },▸ "tempC": {▸ "type": "number"▸ }▸ },▸ "required": [▸ "city",▸ "tempC"▸ ]▸ }▸ }▸ }▸ }'User messages may include OpenAI/AI SDK multimodal parts. Ashna routes attachments per foundation model provider:
gpt-4o-mini), Groq, and many OpenAI-compatible hosts extract PDF text before the model call.import { createOpenAI } from '@ai-sdk/openai';import { generateText } from 'ai';import { readFileSync } from 'fs'; const ashnaAI = createOpenAI({ baseURL: 'https://api.ashna.ai/v1/api'//api.ashna.ai/v1/api', apiKey: process.env.ASHNA_API_KEY,}); const pdfBytes = readFileSync('./report.pdf'); const result = await generateText({ model: ashnaAI.chat('gpt-4o-mini'), messages: [ { role: 'user', content: [ { type: 'text', text: 'Summarize this PDF and describe the image.' }, { type: 'file', data: pdfBytes, mediaType: 'application/pdf', filename: 'report.pdf' }, { type: 'image', image: readFileSync('./chart.png'), mediaType: 'image/png' }, ], }, ],});{ "model": "gpt-4o-mini", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "What is in this image and PDF?" }, { "type": "image_url", "image_url": { "url": "data:image/png;base64,..." } }, { "type": "file", "file": { "filename": "hello.pdf", "file_data": "data:application/pdf;base64,..." } } ] } ]}Set stream: true for OpenAI-compatible SSE (chat.completion.chunk events, ending with data: [DONE]).
import { createOpenAI } from '@ai-sdk/openai';import { streamText } from 'ai'; const ashnaAI = createOpenAI({ baseURL: 'https://api.ashna.ai/v1/api'//api.ashna.ai/v1/api', apiKey: process.env.ASHNA_API_KEY,}); const result = streamText({ model: ashnaAI.chat("gpt-4o-mini"), messages: [ { role: 'user', content: "Say hello in one short sentence." } ], maxOutputTokens: 100, temperature: 0.7,}); for await (const chunk of result.textStream) { process.stdout.write(chunk);}data: {"id":"chatcmpl-...","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"role":"assistant","content":""},"finish_reason":null}]} data: {"id":"chatcmpl-...","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"Hello"},"finish_reason":null}]} data: {"id":"chatcmpl-...","object":"chat.completion.chunk","choices":[{"index":0,"delta":{},"finish_reason":"stop"}],"usage":{"prompt_tokens":12,"completion_tokens":4,"total_tokens":16}} data: [DONE]POST /v1/api/completions uses the same pipeline as Chat Completions for SDK compatibility. Prefer /chat/completions. You can send prompt (string) or messages; the response shape is still a chat completion object from this shared pipeline.
/v1/api/completions▸ curl https://api.ashna.ai/v1/api/completions \▸ -H "Authorization: Bearer YOUR_API_KEY" \▸ -H "Content-Type: application/json" \▸ -d '{▸ "model": "gpt-4o-mini",▸ "prompt": "Reply with exactly: ping",▸ "max_tokens": 20▸ }'Point Cursor, Claude Code, Codex, VS Code, Cline, OpenClaw, or Continue at https://api.ashna.ai/v1/api. Create a key in Account → API. Claude Code uses POST /v1/messages; Codex uses POST /responses; Cursor and VS Code use POST /chat/completions.
Cursor
Install Cursor or the Cursor CLI, paste an Account → API key, and set Override OpenAI Base URL to https://api.ashna.ai/v1/api.
Read the guideClaude Code
Install the Claude Code CLI, then set ANTHROPIC_BASE_URL=https://api.ashna.ai/v1/api and ANTHROPIC_API_KEY to your AshnaAI key.
Read the guideCodex, Cline, OpenClaw
Point Codex CLI, OpenClaw, Cline, or Continue at the same base URL. Codex uses /responses; Cline and Continue use /chat/completions.
Read the guideVS Code
Add a Custom Endpoint in VS Code Language Models. Base URL https://api.ashna.ai/v1/api, then pick a catalog id such as glm-5.3-flash.
Read the guideAny catalog model
Create a key, list ids from GET /models, then POST /chat/completions with that id. Works for GLM, GPT, Claude, Kimi, or a custom agent.
Read the guideOpenAI SDKs talk Chat Completions — only the base URL and API key change. Claude Code is an Anthropic Messages client: export ANTHROPIC_BASE_URL and ANTHROPIC_API_KEY, then see Messages (Claude Code) or the full walkthrough. Keys come from Account → API.
Install tips: npm i ai @ai-sdk/openai · npm i openai · pip install openai · go get github.com/openai/openai-go/v3 · OpenAI Java SDK via Maven/Gradle (com.openai:openai-java).
import { createOpenAI } from '@ai-sdk/openai';import { generateText } from 'ai'; const ashnaAI = createOpenAI({ baseURL: 'https://api.ashna.ai/v1/api'//api.ashna.ai/v1/api', apiKey: process.env.ASHNA_API_KEY,}); const { text } = await generateText({ model: ashnaAI.chat("gpt-4o-mini"), messages: [ { role: 'user', content: "Hello!" } ], maxOutputTokens: 100, temperature: 0.2,}); console.log(text);