API Overview
Moyi API passes each vendor's native protocol straight through: point the official SDK's base URL at Moyi API and keep your code unchanged. The base URL is https://api.moyiapi.com (https://api.moyiapi.cn for the China site); usage and billing endpoints are reachable both there and under the site domain https://moyiapi.com.
Requests
Request format
Pick the protocol by model. Endpoints and request bodies match the corresponding official API:
| Protocol | Endpoint | Models |
|---|---|---|
| Anthropic native | POST /v1/messages |
All Claude models (the recommended entry point) |
| OpenAI compatible | POST /v1/chat/completions |
GPT, Gemini (not recommended for Claude) |
| OpenAI Responses | POST /v1/responses |
GPT only |
| Gemini native | POST /v1beta/models/{model}:generateContent |
Gemini only |
| Images | POST /v1/images/generations, POST /v1/images/edits |
gpt-image-2 |
Calling Claude through the OpenAI-compatible format loses prompt caching, thinking, and similar capabilities; calling Claude or Gemini through the Responses API returns 400. Request bodies are JSON with content-type: application/json.
Headers
There are three auth headers (Authorization: Bearer, x-api-key, x-goog-api-key); see Authentication for where each applies. The Anthropic anthropic-version header is optional.
Responses
Finish reason
Each protocol reports why generation stopped in its own field:
| Protocol | Field | Common values |
|---|---|---|
| Anthropic | stop_reason |
end_turn, tool_use |
| OpenAI | choices[].finish_reason |
stop, tool_calls |
| Gemini | candidates[].finishReason |
STOP |
Querying cost and stats
Every response includes token usage: usage for Anthropic and OpenAI, usageMetadata for Gemini, with protocol-specific field names. Every call also returns an x-request-id response header, which you can pass to Get request usage for the request's final cost; for time-range totals see Get token usage and Get cost summary.