• Home
  • Search
  • AI Services
  • Models
  • Writing
  • Multimedia Creation
  • Translation & Others
Home›Developer Center›API Quick Start

API Quick Start

API DocumentationAPI Quick StartOpenAI ChatGPT APIAnthropic (Claude) APIGoogle Gemini APIGoogle Search APIGoogle News APIOpenRouter APIAPI Pricing
CLI & Agent Guidescc-switch macOScc-switch Windowscc-switch LinuxOpenCode macOSOpenCode WindowsOpenCode LinuxOpenClaw macOSOpenClaw WindowsOpenClaw LinuxHermes Agent macOSHermes Agent WindowsHermes Agent LinuxClaude Code CLI macOSClaude Code CLI WindowsClaude Code CLI LinuxCodex CLI macOSCodex CLI WindowsCodex CLI Linux
MYAI168 API & MCPMYAI168 Chat API GuideMYAI168 MCP CLIMYAI168 MCP Web & App
No matching questions on this page.Search the whole site
API overview and your first call

This site provides OpenAI-compatible, Anthropic (Claude)-compatible, Google and OpenRouter relay APIs, plus site-native utility APIs (Google Search / News, chat, credits) and an MCP server. Usage is billed to your account credits; failed calls are never charged.

Get started in three steps:

  1. Create an API key on the Developer API Key page.
  2. Choose the Base URL that matches the SDK or tool you use (see "Base URLs" below).
  3. Send a request with the key in the Authorization: Bearer YOUR_API_KEY header, for example:
curl https://www.myai168.com/en/api/openai/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"gpt-6.1-sol","messages":[{"role":"user","content":"Hello"}]}'

A successful call returns the standard OpenAI JSON: the reply text is in choices[0].message.content, and the response headers carry the points charged (X-Cost-Points) and your remaining balance (X-Credits-Remaining).

The same call in Python (install the package first with pip install requests):

import requests

r = requests.post(
    "https://www.myai168.com/en/api/openai/v1/chat/completions",
    headers={"Authorization": "Bearer YOUR_API_KEY"},
    json={"model": "gpt-6.1-sol", "messages": [{"role": "user", "content": "Hello"}]},
    timeout=600,
)
r.raise_for_status()
print(r.json()["choices"][0]["message"]["content"])
print("cost:", r.headers.get("X-Cost-Points"), "remaining:", r.headers.get("X-Credits-Remaining"))

List the models each relay accepts with GET https://www.myai168.com/en/api/openai/v1/models or GET https://www.myai168.com/en/api/anthropic/v1/models — the returned list is exactly what the relay accepts; other models are rejected with No pricing info! Please use other models!.

Each relay page includes official SDK examples (for example OpenAI ChatGPT API); CLI tools such as Claude Code and Codex have step-by-step guides under "CLI & Agent Guides" in the Developer Center.

Base URLs
NameBase URLUse it forBase URL for the official SDKDocumentation
OpenAI-compatiblehttps://www.myai168.com/en/api/openai/v1OpenAI SDK, Codex and other OpenAI-compatible tools; GPT models, decisions, images, speech and embeddings.Same as the Base URLOpenAI ChatGPT API
Anthropic (Claude)https://www.myai168.com/en/api/anthropic/v1Anthropic SDK and Claude Code; Claude models.https://www.myai168.com/en/api/anthropic (without /v1 — the SDK adds it)Anthropic (Claude) API
Googlehttps://www.myai168.com/en/api/google/v1betaGoogle Gen AI SDK; Gemini models, image generation and speech.https://www.myai168.com/en/api/google (without /v1beta — the SDK adds it)Google Gemini API
OpenRouter-compatiblehttps://www.myai168.com/en/api/openrouter/v1Models from many vendors through one Chat Completions format; text-to-speech (ElevenLabs and others) and video generation.OpenAI SDK: same as the Base URLOpenRouter API

REST calls (curl, requests) use the Base URL plus the endpoint path, for example https://www.myai168.com/en/api/anthropic/v1/messages. Official SDKs add the version path themselves, so the Anthropic and Google SDKs take a shorter base URL — a wrong base URL is the most common cause of 404 errors.

To use the image, speech and video generation modules enabled on this site, call the site-native chat endpoint instead — see MYAI168 Chat API Guide.

Authentication

Create an API key on the Developer API Key page, then send it with every request:

  • Authorization: Bearer YOUR_API_KEY — works on all endpoints (recommended).
  • x-api-key: YOUR_API_KEY — also accepted on Anthropic (Claude) endpoints (SDK compatible).
  • x-goog-api-key: YOUR_API_KEY — also accepted on Google endpoints (SDK compatible).
  • X-Dev-Key: YOUR_API_KEY — also accepted on the site-native Google Search / News, chat and MCP endpoints.

Never place API keys in URL query strings — URLs are recorded in access logs and browser history. Endpoints do not accept keys via query parameters.

Streaming

Chat Completions, Responses, Anthropic Messages and Gemini streamGenerateContent support streaming. Send "stream": true (or use the streaming endpoint) and read the response as Server-Sent Events (data: {JSON} lines). With curl, add -N (--no-buffer) to see tokens as they arrive.

Each relay keeps its vendor's own event format: OpenAI Chat Completions sends data: chunks and ends with data: [DONE]; the Responses API and Anthropic Messages send named events (response.output_text.delta and content_block_delta carry the text); Gemini sends plain data: chunks. Each relay page shows a full sample.

Prefer streaming for long outputs or high reasoning effort: the relay waits up to about 10 minutes for the model, and a non-streaming call returns nothing until the whole reply is ready.

Billing and response headers

Usage is billed to your account credits. Non-streaming relay responses include X-Cost-Points (points charged for this call) and X-Credits-Remaining (your balance after the call). Streaming responses cannot carry these headers; instead, after the final event (e.g. data: [DONE]) the stream ends with SSE comment lines carrying the same information:

: cost=12
: credits-remaining=34567

Comment lines (starting with :) are skipped by spec-compliant SSE parsers and official SDKs, so they never affect compatibility; Google Gemini streaming does not send them. Read them from the raw stream if you want per-call charges. You can always query GET https://www.myai168.com/en/api/user/get_credits. Failed calls are never charged.

Error handling
HTTP statusMeaning
400 + No pricing info! Please use other models!The requested model is not on this relay's supported list — call the /models endpoint for the accepted list.
400Invalid request body, or an unsupported hosted / server-side tool was requested.
401Missing or invalid API key. Repeated failures from the same IP are rate-limited.
401 + API key credit limit reached!This key has reached the credit limit set on the Developer API Key page; raise the limit or use another key.
402Insufficient credits (Insufficient credits. Please top up! / You need to top up!).
404The endpoint does not exist, or this site has not enabled the external API service (External API service is not available on this site.).
405Wrong HTTP method (for example GET on an endpoint that only accepts POST).
413The request body exceeds the size limit of this site.
429 / 5xxRate limiting or overload reported by the upstream vendor — the status code and error body are passed through unchanged.
500Temporary server error — never charged; please retry later.
502Upstream vendor error — never charged.

Error responses are JSON with the message in error.message. No error is ever charged.

How to handle them: for 400 / 404 / 405 fix the request (retrying will not help); for 401 check the key and its credit limit; for 402 top up; for 429 and 5xx wait and retry with increasing delays (for example 2, 4, then 8 seconds).

Best practices
  • Keep keys on the server: never put an API key in web pages, mobile apps or public repositories — call the API from your own backend.
  • Use one key per application and set a credit limit on each key (Developer API Key page), so a runaway program cannot drain the account; delete a leaked key right away.
  • Set a client timeout of about 600 seconds for non-streaming calls, or use streaming for long outputs.
  • Check why a reply ended (finish_reason / stop_reason / finishReason) before using it — a reply cut off at the token limit looks like a normal one.
  • Model ids must match the /models list exactly; refresh the list from time to time, because vendors retire models.
  • Reasoning (thinking) tokens count as output: leave room in the output limit, and lower the reasoning effort for simple tasks to save credits.
  • Track spending with the X-Cost-Points and X-Credits-Remaining response headers, or query GET https://www.myai168.com/en/api/user/get_credits at any time.
Site-native API endpoints
EndpointMethodDescriptionDocumentation
https://www.myai168.com/en/api/google/searchGETGoogle web search (structured JSON results).Google Search API
https://www.myai168.com/en/api/google/newsGETGoogle News search (JSON results with resolved article URLs).Google News API
https://www.myai168.com/en/api/user/get_creditsGETQuery your remaining credits (free).—
Next page: OpenAI ChatGPT API ›
↑
Question link copied.

Other FAQ pages

API Documentation

  • OpenAI ChatGPT API
  • Anthropic (Claude) API
  • Google Gemini API
  • Google Search API
  • Google News API
  • OpenRouter API
  • API Pricing

CLI & Agent Guides

  • cc-switch macOS
  • cc-switch Windows
  • cc-switch Linux
  • OpenCode macOS
  • OpenCode Windows
  • OpenCode Linux
  • OpenClaw macOS
  • OpenClaw Windows
  • OpenClaw Linux
  • Hermes Agent macOS
  • Hermes Agent Windows
  • Hermes Agent Linux
  • Claude Code CLI macOS
  • Claude Code CLI Windows
  • Claude Code CLI Linux
  • Codex CLI macOS
  • Codex CLI Windows
  • Codex CLI Linux

MYAI168 API & MCP

  • MYAI168 Chat API Guide
  • MYAI168 MCP CLI
  • MYAI168 MCP Web & App