Documentation
Configure your API endpoint and key via environment variables — no code changes needed to integrate PioModel.
01API Endpoints
02Environment Variables
Windows Setup
Valid for the current terminal session only. Closes when the window closes. Good for quick testing.
macOS / Linux Setup
Valid for the current terminal session only. Closes when the window closes. Good for quick testing.
03Tool Integration
Mainstream AI coding tools can connect directly to PioModel — just set the environment variables or configuration below.
Claude Code CLI
Anthropic's official CLI — connect to PioModel via environment variables, no code changes needed.
Go to API Key Management to download a one-click setup script →Then launch with:
Codex CLI
OpenAI's official Codex CLI — uses the /v1/responses endpoint. Note: base_url must include /v1.
Edit ~/.codex/config.toml:
Then set the API key as an environment variable:
Then launch with:
Cursor / Windsurf
Override the OpenAI endpoint and API key in the settings.
Cline (VS Code)
Select the OpenAI Compatible provider in Cline and enter the endpoint, key, and model name.
04Code Examples
Install: pip install anthropic / openai · npm install openai
05Streaming
Add stream: true to your request body to enable SSE streaming — ideal for real-time chat UIs.
06Automatic Format Conversion
PioModel performs transparent two-way conversion between Anthropic Messages and OpenAI Chat at the gateway level. This means you can call the same model in either Anthropic style or OpenAI style — one codebase, any model.
Key field mappings between the two styles:
| Anthropic Style | OpenAI Style | Description |
|---|---|---|
| system | messages[role=system] | System prompt is positioned differently; the gateway handles it automatically |
| max_tokens(必填) | max_tokens(可选) | When omitted, the gateway applies the model's default limit |
| content 分块数组 | content 字符串 | Text/image blocks convert to and from strings |
| stop_reason | finish_reason | Finish reason field name mapping |
07Multimodal
Image generation uses the same gateway and API key, billed by usage.
08Function Calling
Define callable functions using OpenAI-style tools. The model returns tool_calls when needed, and your code executes them and returns the results.
09Error Handling
/v1/* endpoints follow OpenAI's error format — responses contain type / code / message.
Common error codes
| HTTP | Description |
|---|---|
| 401 | API key is invalid or missing |
| 402 | Insufficient balance — please top up |
| 429 | Rate limited or daily quota exhausted |
| 503 | All upstream channels unavailable (circuit broken) |