Quickstart
Moyi API serves Claude, GPT, Gemini, and other models behind a single API key. Send each request in the protocol its model belongs to; responses keep each protocol's original structure.
Using the Moyi API API
- Create an API key (starting with
sk-moyiapi-) in the dashboard. - Send your first request. Claude, for example:
curl https://api.moyiapi.com/v1/messages \
-H "x-api-key: sk-moyiapi-xxxxxx" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{
"model": "claude-sonnet-5",
"max_tokens": 256,
"messages": [{"role": "user", "content": "Hello"}]
}'
Python:
import requests
resp = requests.post(
"https://api.moyiapi.com/v1/messages",
headers={
"x-api-key": "sk-moyiapi-xxxxxx",
"anthropic-version": "2023-06-01",
"content-type": "application/json",
},
json={
"model": "claude-sonnet-5",
"max_tokens": 256,
"messages": [{"role": "user", "content": "Hello"}],
},
)
print(resp.json()["content"][0]["text"])
TypeScript:
const resp = await fetch("https://api.moyiapi.com/v1/messages", {
method: "POST",
headers: {
"x-api-key": "sk-moyiapi-xxxxxx",
"anthropic-version": "2023-06-01",
"content-type": "application/json",
},
body: JSON.stringify({
model: "claude-sonnet-5",
max_tokens: 256,
messages: [{ role: "user", content: "Hello" }],
}),
});
const data = await resp.json();
console.log(data.content[0].text);
Example response
{
"id": "msg_01KxDE...",
"type": "message",
"role": "assistant",
"model": "claude-sonnet-5",
"content": [{"type": "text", "text": "Hello! How can I help you?"}],
"stop_reason": "end_turn",
"usage": {"input_tokens": 9, "output_tokens": 12}
}
The reply text sits in the content block whose type is text. Full field descriptions are on Create a message.
A failed call returns an error object plus a top-level trace_id. The common ones are 401 (wrong key) and 402 (out of credit); see Errors for the full table.
Switching models means switching protocol: Claude uses the Anthropic native format, GPT the OpenAI-compatible format, Gemini the Gemini native format. See the API Overview for the full mapping. Model IDs are authoritative in GET /v1/models.
Using the official SDKs
Set the SDK's api_key to your key and base_url to Moyi API; your code stays the same. Anthropic SDK: https://api.moyiapi.com; OpenAI SDK: https://api.moyiapi.com/v1; Google GenAI SDK: https://api.moyiapi.com. SDK examples are on the endpoint pages: Create a message, Create a chat completion, Generate content.
Using agent tools
Claude Code, Codex, Cursor, and other tools only need their base URL and key switched to Moyi API. Per-tool steps are in the Integrations guides.
Next steps
- Which endpoints each protocol supports: API Overview
- Tokens as they are generated: Streaming
- Sampling parameter names in each protocol: Parameters
- Letting the model call your functions: Tool calling
- Sending images to a model: Image inputs