API Reference

Quick Start

OpenAI compatible. Drop in with 3 lines of code.

1. Get API Key

Log in to AICraft Console, go to API Keys, create a key. Format: sk- + 40 hex.

Keep your API Key secret. Never expose it in client code or repos.

2. Base URL

Base URL

API Gateway

https://aicraftapi.net/v1

3. First Call

curl https://aicraftapi.net/v1/chat/completions   -H "Content-Type: application/json"   -H "Authorization: Bearer YOUR_API_KEY"   -d '{"model":"auto","messages":[{"role":"user","content":"Hello!"}]}'
# pip install openai
from openai import OpenAI
client = OpenAI(api_key="YOUR_API_KEY", base_url="https://aicraftapi.net/v1")
response = client.chat.completions.create(model="auto", messages=[{"role":"user","content":"Hello!"}])
print(response.choices[0].message.content)
// npm install openai
import OpenAI from "openai";
const client = new OpenAI({ apiKey: "YOUR_API_KEY", baseURL: "https://aicraftapi.net/v1" });
const r = await client.chat.completions.create({ model: "auto", messages: [{ role: "user", content: "Hello!" }] });
console.log(r.choices[0].message.content);
// go get github.com/openai/openai-go
package main
import ("context"; "fmt"; openai "github.com/openai/openai-go"; "github.com/openai/openai-go/option")
func main() {
    c := openai.NewClient(option.WithAPIKey("YOUR_API_KEY"), option.WithBaseURL("https://aicraftapi.net/v1"))
    r, _ := c.Chat.Completions.New(context.Background(), openai.ChatCompletionNewParams{
        Model: openai.String("auto"),
        Messages: openai.F([]openai.ChatCompletionMessageParamUnion{openai.UserMessage("Hello!")}),
    })
    fmt.Println(r.Choices[0].Message.Content)
}
Set model: "auto" to enable Auto Router — automatically picks the best model.

Download Tools (Step-by-Step)

Tools to get the most out of AICraft. Install in order: ① Node.js → ② VS Code → ③ Claude Code. Every step includes a verification check. If you get stuck, see the troubleshooting table in Step ③.

① Node.js (Prerequisite)

Node.js + AICraft

Claude Code is a terminal tool that runs on Node.js. Install Node.js 18+ first — we recommend the 22 LTS stable release.

Download Node.js 22 LTS

Installation Steps

  1. Download: Click "Download Node.js 22 LTS" above to open the official page.
  2. Version: Click the big green Download Node.js 22 LTS button (auto-detects your OS).
  3. Install: Double-click the installer → Next → Finish. Windows users: make sure "Add to PATH" is checked (it is by default).
  4. Verify: Open a terminal (Windows: Win+R → type cmd → Enter; Mac: "Terminal" app), run:
    node -v
    You should see v22.x.x ✅. Then run npm -v — if it prints a version too, everything is ready.
If you see "'node' is not recognized", the install failed or "Add to PATH" wasn't checked — just reinstall it.

② VS Code

VS Code + AICraft

VS Code is the editor (free, no login needed). Two ways to use it: A. Run Claude Code in the terminal (recommended, most powerful); B. Install the Cline extension for in-editor AI. You can use both.

Download VS Code

Installation Steps

  1. Download: Click "Download VS Code" above and pick your OS (Windows / Mac).
  2. Install: Double-click → Next. On Windows, tick "Add to PATH" and the "Open with Code" context-menu option.
  3. Verify: Open VS Code — if the welcome page appears, you're done ✅.

Play B: Cline Extension (In-Editor AI Chat)

  1. In VS Code, click the Extensions icon (4 squares) on the left, search Cline, click Install.
  2. Click the Cline icon on the right sidebar to open its panel.
  3. Set API Provider to OpenAI Compatible.
  4. Fill in the fields below (use the API Key you create in ③ Step 2):
SettingValue
Base URLhttps://aicraftapi.net/v1 (⚠️ must include /v1 — the opposite of Claude Code)
API Keysk-YOUR_KEY (replace with your real Key)
Modelauto
Ask anything after filling it in — a reply means Cline is configured successfully.

③ Claude Code Setup (Step-by-Step)

Claude Code is Anthropic's terminal AI coding agent — the core of this guide. Follow these 6 steps.

Step 1: Install Claude Code

Prerequisite: Node.js 18+ (go back to ① Node.js if you haven't installed it).

Option A (recommended) — official one-click script:

  1. Download: Download Install Script
  2. Open a terminal in the script's folder (Mac / Linux) and run bash install-claude-code.sh
  3. When prompted > , paste the API Key you created, press Enter
  4. The script installs Claude Code AND writes the config for you. When you see Done!, you're all set ✅

Option B — manual install: pick your OS:

# Option 1: Official native installer (recommended, auto-updates)
curl -fsSL https://claude.ai/install.sh | bash

# Option 2: npm install (fallback, requires Node.js)
npm install -g @anthropic-ai/claude-code

# Verify
claude --version
:: Windows — pick one:

:: Option A (recommended): install WSL first (Microsoft Store, search "WSL"),
:: then run this in the Ubuntu terminal:
curl -fsSL https://claude.ai/install.sh | bash

:: Option B (quick): use npm with Node.js
npm install -g @anthropic-ai/claude-code
Official native installer is recommended. npm still works but is being deprecated by Anthropic.

Verify: run claude --version — a version number means success ✅

Step 2: Get Your API Key

  1. Log in to the AICraft Console
  2. Find the "API Key" card → click "Create"
  3. Copy the generated key — it starts with sk- followed by 40 hex characters
⚠️ Your key is shown in full only once — copy and save it immediately. Lost it? Create a new one. Note: it looks like sk-a1b2c3..., not sk-YOUR_KEY.

Step 3: Configure settings.json

Used the one-click script? It wrote the config for you — skip this step, go to Step 4.
Manual install? Find (or create) the config file:

OSPath
macOS / Linux~/.claude/settings.json
Windows%USERPROFILE%\.claude\settings.json (i.e. C:\Users\YOURNAME\.claude\settings.json)

If the .claude folder doesn't exist, create it first:

mkdir -p ~/.claude && touch ~/.claude/settings.json
New-Item -ItemType Directory -Force -Path "$HOME\.claude" | Out-Null
New-Item -ItemType File -Force -Path "$HOME\.claude\settings.json" | Out-Null

Paste this, replacing YOUR_API_KEY with your real key:

{
  "env": {
    "ANTHROPIC_BASE_URL": "https://aicraftapi.net",
    "ANTHROPIC_AUTH_TOKEN": "YOUR_API_KEY",
    "ANTHROPIC_MODEL": "auto",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "auto",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "auto",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "auto",
    "CLAUDE_CODE_SUBAGENT_MODEL": "auto"
  }
}
VariableReqDescription
ANTHROPIC_BASE_URLYesAPI Gateway aicraftapi.net (no /v1 — Claude Code appends it)
ANTHROPIC_AUTH_TOKENYesAPI Key, format sk-xxx
ANTHROPIC_MODELYesDefault model. "auto" enables Auto Router
ANTHROPIC_DEFAULT_OPUS_MODELNoOpus tier mapping
ANTHROPIC_DEFAULT_SONNET_MODELNoSonnet tier mapping
ANTHROPIC_DEFAULT_HAIKU_MODELNoHaiku tier mapping
CLAUDE_CODE_SUBAGENT_MODELNoSub-agent model, keep consistent with main
⚠️ ANTHROPIC_BASE_URL must NOT include /v1 — Claude Code appends /v1/messages automatically. Adding it causes a 404.
Map every tier to "auto" — Router picks the best model per task: DeepSeek for coding, Qwen for Chinese, Claude for complex reasoning.

Step 4: Verify the Connection

  1. Open a new terminal and cd to your project:
    cd your-project
    claude
  2. After startup, type /status and check:
CheckShould be
API Endpointaicraftapi.net
Modelauto
  1. Ask: "Hi, introduce yourself." → a reply means everything works ✅
If it keeps asking you to log in to Anthropic, settings.json isn't taking effect — check the path and content in Step 3.

Step 5: Use It With VS Code (Vibe Coding)

  1. In VS Code: File → Open Folder → select your project
  2. Press Ctrl+` to open the built-in terminal
  3. Type claude and press Enter
  4. Let Claude edit code — changes appear live in the editor

Step 6: Enable Deep Reasoning (Optional)

Type /config in Claude Code → set Thinking mode to true → quit and re-enter.

Troubleshooting

SymptomCauseFix
Claude keeps asking to log in to Anthropicsettings.json is wrongRecheck path & content in Step 3
404 / "model problem"base URL has /v1Remove /v1 — keep only aicraftapi.net
Rate-limited / no quotaNo top-upTop up in Console, min $1
401 Invalid keyKey typo / unverified emailRecheck key; click email verification link
npm install failsNo Node.js / networkInstall Node.js (Step ①) or use WSL
Cline can't connectBase URL missing /v1Cline uses aicraftapi.net/v1 (with /v1)

Does Web Search work?

Yes. AICraft doesn't block native search. For MCP search: Tencent Cloud MCP Marketplace.

Which model does "auto" pick?

Router picks per task: DeepSeek for coding, Qwen for Chinese, MiniMax for creative. Check the X-AICraft-Routed-To header. See Auto Router.

④ Codewhale (Terminal AI Coding Assistant)

Codewhale is an open-source terminal coding assistant that works with any OpenAI-compatible API. If you already use AICraft, add the config below and it will call our models.

Step 1: Install Codewhale

macOS / Linux:

curl -fsSL https://codewhale.net/install.sh | sh

Windows: download the installer from GitHub Releases. Already installed? Upgrade with codewhale update.

Step 2: Write the Config

Edit ~/.codewhale/config.toml (on Windows, %USERPROFILE%\.codewhale\config.toml) and add:

provider = "aicraft"

[providers.aicraft]
kind = "openai-compatible"
base_url = "https://aicraftapi.net/v1"
api_key = "sk-YOUR_KEY"
model = "claude-4.5-sonnet"
⚠️ Keep base_url ending at /v1. Do not append /chat/completions — the client adds it, and the duplicated path returns 404.

Step 3: Start Using It

From your project directory run codewhale, choose aicraft under /provider and a model under /model, then describe the task.

Model IDs come from the Model Catalog and can be pasted into the config as-is.

⑤ Switch Providers With CC Switch (Windows / Mac GUI)

CC Switch is a free, open-source provider switcher for Claude Code. It writes ~/.claude/settings.json for you through a GUI, so you can flip between providers with one click instead of editing config by hand. Use it or the manual settings.json route above — not both.

  1. Install: search GitHub for farion1231/claude-code-switch, or grab the Windows / Mac installer from its website (a CC Switch icon appears on your desktop).
  2. Open CC Switch → "Add Provider" and fill in:
FieldValue
Provider nameAICraft (anything you like)
API Endpoint (Base URL)https://aicraftapi.net (⚠️ no /v1!)
API Keysk- + 40 hex characters (created in the console)
ModelAny model ID from the Model Catalog, or auto
🚫 Two things to get right:
① Do not put /v1 in the Base URL. CC Switch writes a Claude Code config, and Claude Code appends its own path (/v1/messages); a Base URL that already ends in /v1 produces a duplicated path and 404s. This is the same reason ANTHROPIC_BASE_URL is written without /v1 in the Claude Code step above.
② Use exact model IDs. claude-4.5-sonnet is valid; a near-miss spelling is not, and comes back as a model error.
Click "Switch to AICraft" → run claude in your terminal → a reply to a simple "hello" means it works. Click back to return to Anthropic’s endpoint at any time.

⑥ Skills Pack (Optional)

140 AI development skills covering coding, testing, deployment, security, and docs. Import into Claude Code for direct use.

140 Skills · 5.3MB · 454 Files

CategoryCoverageExamples
CodingPython / TS / Go / API / DB / Frontendpython-patterns fastapi database-design
TestingUnit / Integration / E2E / Perf / TDDtest-driven-development e2e-testing
ReviewCode Review / Security / Performancecode-review-and-quality security
DevOpsCI/CD / Docker / Monitoringci-cd deployment-strategies
DocsTechnical / Articles / Investortechnical-documentation article-writing
AI/LLMPrompt / Agent / RAG / Auditoptimize-prompt langgraph claude-api
Download Skills Pack (5.3MB)

Install

Extract to Claude Code's skills directory:

ToolInstallPath
Claude Code~/.claude/skills/
# 1. Download and extract
unzip aicraft-skills.zip -d ~/.claude/skills/

# 2. Verify
ls ~/.claude/skills/
# You should see 140 skill directories (python / fastapi / code-review ...)
:: 1. Download aicraft-skills.zip
:: 2. Extract to %USERPROFILE%\.claude\skills (right-click zip → Extract to .claude\skills)

:: 3. Verify with PowerShell
dir $env:USERPROFILE\.claude\skills\

Usage

Type /skill-name in Claude Code to invoke a skill. Examples:

/python-patterns         # Python design pattern guidance
/code-review             # Review current code
/test-driven-development # TDD workflow
/deployment-strategies   # Deployment advice
/security                # Security review
/api-design              # API design best practices
140 skills cover the full dev lifecycle. Got a task → check INDEX.md → invoke the matching skill → execute.

API Reference

Chat Completions

POST/v1/chat/completions

OpenAI-compatible chat completions endpoint.

Parameters

ParameterTypeReqDefaultDescription
modelstringYes—"auto" or specify a Model name
messagesarrayYes—Messages array. role: system/user/assistant
streambooleanNofalseSSE streaming output
temperaturenumberNo1Temperature 0-2. Higher = more random
max_tokensintegerNo—Max output tokens
top_pnumberNo1Nucleus sampling
frequency_penaltynumberNo0 -2.0 to 2.0. Positive value reduces repetition
presence_penaltynumberNo0 -2.0 to 2.0. Positive value encourages novelty
stopstring/arrayNo—Stop sequence(s)

Response

{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1720000000,
  "model": "deepseek/deepseek-v4-pro",
  "choices": [{
    "message": { "role": "assistant", "content": "Hello! How can I help?" },
    "finish_reason": "stop"
  }],
  "usage": { "prompt_tokens": 10, "completion_tokens": 8, "total_tokens": 18 }
}
With model: "auto", the response model field shows the Router-selected model.

Streaming (SSE)

Set "stream": true:

data: {"choices":[{"delta":{"content":"Hello"}}]}

data: {"choices":[{"delta":{"content":" world"}}]}

data: {"choices":[{"finish_reason":"stop"}]}

data: [DONE]

Each chunk is data: {json}. Ends with data: [DONE]. OpenAI SDK handles this.

Jev Native Endpoints

Three models are served over their native protocol instead of chat messages: typesafe/jev-1.13, typesafe/jev-1.14 and microsoft/microsoft-decision-1. Send one POST to one of the two endpoints below and you get structured answers back. "model": "jev-latest" resolves to the newest version currently on sale.

These are not chat models. Calling one of them on /v1/chat/completions or /v1/messages returns 400 with This model does not accept /v1/chat/completions. Use /v1/systemone or /v1/decisions. — the model exists, it simply has no chat entry.

Question types

TypeEndpointReturns
noul/v1/systemoneConfidence between 0 and 1
choicebothThe chosen value
score/v1/systemoneScore with per-level probabilities and confidence
predicate/v1/decisionsTrue/false with a probability
score is available on /v1/systemone only. On /v1/decisions it is refused up front with 400 unsupported_question_type, before any tokens are spent — use /v1/systemone instead. Streaming is not supported on either endpoint.

SystemOne

POST/v1/systemone

Score or classify a single state against one or more named questions.

Parameters

ParameterTypeReqDescription
modelstringYesOne of the three native models, or jev-latest
statestring / array / objectYesThe text to evaluate
questionsobjectYesUp to 50 named questions. Key = answer name, value = {"type": "...", "instructions": "..."}
streambooleanNoNot supported; ignored

Example

curl https://aicraftapi.net/v1/systemone \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "typesafe/jev-1.14",
    "state": "今天天气不错",
    "questions": {
      "is_zh": { "type": "noul", "instructions": "这段是中文吗?" }
    }
  }'
{
  "model": "typesafe/jev-1.14",
  "answers": {
    "is_zh": { "type": "noul", "noul": 0.99 }
  },
  "usage": { "input_tokens": 280, "output_tokens": 22, "total_tokens": 302 },
  "id": "jev-9f1c2b7e4a6d8c0e"
}
answers is keyed by the question name you sent. Billing reads the usage block; a request rejected with 400 is not billed.

Decisions

POST/v1/decisions

Run one or more decisions over a single input and get an ordered array of answers.

Parameters

ParameterTypeReqDescription
modelstringYesOne of the three native models, or jev-latest
inputstring / array / objectYesThe text to decide on
questionsarrayYesUp to 50 questions, each {"type": "...", "name": "...", "instructions": "..."} (name optional). Answer order follows this array
streambooleanNoNot supported: returns 400 unsupported_parameter and points to /v1/systemone

Example

curl https://aicraftapi.net/v1/decisions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "microsoft/microsoft-decision-1",
    "input": "今天天气不错",
    "questions": [
      { "type": "predicate", "name": "is_zh", "instructions": "中文吗?" }
    ]
  }'
{
  "model": "microsoft/microsoft-decision-1",
  "answers": [
    { "type": "predicate", "name": "is_zh", "probability": 0.99 }
  ],
  "usage": { "input_tokens": 280, "output_tokens": 21, "total_tokens": 301 },
  "id": "jev-4c8d1e6f9b2a7350"
}
Every native reply carries model, answers, usage and id. A request we cannot serve is answered with a JSON error object carrying code (for example model_not_found, unsupported_question_type) and is never charged.

Model List

GET/v1/models

List available models. Full catalog: Model Catalog.

curl https://aicraftapi.net/v1/models -H "Authorization: Bearer YOUR_API_KEY"

Auto Router v6

model: "auto" activates the core routing engine.

12 Routing Categories

TaskPrimary ModelFallback
Codingdeepseek/deepseek-v4-prodeepseek/deepseek-v4-flash
Chineseqwen/qwen3.7-maxz-ai/glm-5
Translationqwen/qwen3.6-plusdeepseek/deepseek-v4-flash
Reasoningz-ai/glm-5deepseek/deepseek-v4-pro-202606
Mathdeepseek/deepseek-v4-pro-202606z-ai/glm-5
Creativeminimax/minimax-m3deepseek/deepseek-v4-flash
Complexclaude-4.5-sonnetopenai/gpt-5.4
Fastdeepseek/deepseek-v4-flashqwen/qwen3.6-plus
Chatqwen/qwen3.6-plusdeepseek/deepseek-v4-flash
Summarydeepseek/deepseek-v3.2-251201qwen/qwen3.6-plus
Writingqwen/qwen3.7-maxdeepseek/deepseek-v4-flash
Analysisx-ai/grok-4.3claude-4.5-sonnet

Response Headers

Response HeadersDescription
X-AICraft-ModeRouting mode (auto / manual)
X-AICraft-CategoryDetected TaskCategory
X-AICraft-Routed-Toactually used model
X-AICraft-SavingsCost saved vs GPT-4

v6 Smart Features

Model Usage & Fallback

Always Use Real Model IDs

The model field takes either auto or an exact model ID in vendor/model lowercase form (for example deepseek/deepseek-v4-pro). Pick IDs from the Model Catalog and copy them verbatim.
An explicit model ID is passed through unchanged — the Router does not substitute a different model for you. The response header X-AICraft-Mode reads manual when you named a model yourself and auto when the Router chose.
Not sure which model fits? Send model: "auto" and the Router classifies the request, then walks that category’s chain (primary → secondary → tertiary → last resort), falling back automatically when a channel fails.

Handling Errors

SymptomWhat to do
504 gateway timeout / long silenceFor long conversations switch to a fast model such as deepseek/deepseek-v4-flash, or trim the context and retry
"Model not found"Copy the exact ID from the Model Catalog, or send auto
429 rate limit exceededSlow down your request rate, or upgrade your plan — concurrency and quota scale with your tier

Guides

Response Cache beta

Two-layer caching saves money automatically. Rolling out gradually.

LayerTechnologySpeedCost
A · Provider Cachecache_control passthrough~200ms90% discount
B · Semantic CacheBGE-small, similarity >0.95<5msFREE
Every 2-3 Requests hit cache. High-frequency use cases (Service, Translation) see better rates.

Rate Limits

PlanTop-upConcurrencyDescription
BasicAny amount (new users get free trial credit)10Pay-per-use · All models
Advanced$1530Faster calls · Daily use
Pro$7080High-speed calls · Frequent development
Enterprise$280200Sub-keys · Team management · Invoice

Returns 429 when exceeded. See Pricing.

Error Codes

CodeMeaningAction
400Bad requestCheck JSON and required fields
401Invalid API KeyVerify Authorization header
429Rate limitedSlow down or upgrade Plan
500Model unavailableRouter retries other models
503Service overloadedRetry shortly, OSauto-scaling

OnlineDebug

0.7
AICraft Assistant · AI-Powered
Powered by AICraft Auto Router

Last reviewed: 2026-10-20