Authentication

Every endpoint authenticates with an API key. Create keys in the dashboard; they start with sk-moyiapi-. Keep them server-side only, never in frontend code or a repository.

Using an API key

Moyi API accepts three headers. Pick the one that matches your protocol or SDK:

Header Endpoints Used by
Authorization: Bearer sk-moyiapi-xxxxxx All endpoints Direct calls, and the OpenAI SDK (api_key)
x-api-key: sk-moyiapi-xxxxxx All endpoints The Anthropic SDK (api_key), together with anthropic-version: 2023-06-01
x-goog-api-key: sk-moyiapi-xxxxxx Gemini native endpoints only (/v1beta/models/...) The Google GenAI SDK

With an official SDK, set api_key to your key and base_url to Moyi API; the SDK sends the matching header for you. Full SDK examples are in Models & routing. For direct calls, any of the three works:

bash
curl https://api.moyiapi.com/v1/chat/completions \
  -H "Authorization: Bearer sk-moyiapi-xxxxxx" \
  -H "content-type: application/json" \
  -d '{
    "model": "gpt-5.6-sol",
    "messages": [{"role": "user", "content": "Hello"}]
  }'

Authentication failures return 401 with error.type explaining why:

error.type When it happens
missing_auth_credential No supported auth header was sent, or only x-goog-api-key was sent to a non-Gemini endpoint
invalid_api_key The key in x-api-key or x-goog-api-key is wrong, incomplete, or deleted
invalid_bearer_token The key in Authorization: Bearer is wrong, incomplete, or deleted

If your key has been exposed

Delete the exposed key in the dashboard and create a new one to replace it. A deleted key no longer authenticates; requests using it receive 401.

Ready? Three steps to startLog in to the console · top up · create an API key
DiscordGet community help instantly
Authentication · Docs