Q: How do I get started quickly?
A: You can complete the integration in as little as five minutes.
Step 1: Get an API Key. For details, see API Key Management .
Step 2: Install the SDK.
Python
pip install openaiNode.js
npm install openaiStep 3: Make an API request.
from openai import OpenAI client = OpenAI( api_key="sk-your-key", base_url="https://api.maitoken.com/v1" # Replace with the platform URL) response = client.chat.completions.create( model="[Model Name]", messages=[ {"role": "system", "content": "You are an intelligent customer support assistant."}, {"role": "user", "content": "Hello"} ]) print(response.choices[0].message.content)Step 4: Test the API with cURL.
curl https://api.maitoken.com/v1/chat/completions \ -H "Authorization: Bearer sk-your-key" \ -H "Content-Type: application/json" \ -d '{"model":"[Model Name]","messages":[{"role":"user","content":"Hello"}]}'Q: Which programming languages and SDKs are supported?
A: Because MaiToken is compatible with the OpenAI API protocol, you can use any language that supports an OpenAI SDK:
Python (
openailibrary)Node.js / TypeScript (
openailibrary)Java (
openai-javalibrary)Go (
go-openailibrary)C# / .NET
PHP / Ruby / Rust and others
Any language that can send requests through the HTTP REST API
Simply replace
base_urlwith https://api.maitoken.com/v1 . This usually requires changing no more than two lines of code.
Q: How do I migrate from the official OpenAI API to MaiToken?
A:
You can switch to MaiToken in five minutes. There is no need to rewrite your code—just change the Base URL and API Key.
Before Migration (Official OpenAI API)
client = OpenAI(api_key="sk-openai-key")After Migration (MaiToken)
client = OpenAI( api_key="sk-your-maitoken-key", # Replace the API Key base_url="https://api.maitoken.com/v1" # Replace the Base URL)Q: Is streaming output (SSE) supported?
A: Yes. Set stream=True to enable streaming output.
response = client.chat.completions.create( model="[Model Name]", messages=[{"role": "user", "content": "Write a poem"}], stream=True # Enable streaming) for chunk in response: if chunk.choices[0].delta.content: print(chunk.choices[0].delta.content, end="")Streaming output can significantly reduce perceived latency, with time to first token below 500 ms. It is recommended for conversational applications.
Q: Is Function Calling / tool calling supported?
A: Yes. Pass the tools parameter in the request:
tools = [{ "type": "function", "function": { "name": "get_weather", "description": "Get the weather for a specified city", "parameters": { "type": "object", "properties": { "city": { "type": "string", "description": "City name" } }, "required": ["city"] } }}] response = client.chat.completions.create( model="[Model Supporting Function Calling]", messages=[ { "role": "user", "content": "What is the weather like in Beijing today?" } ], tools=tools)Note: Not all models support Function Calling.
Q: Is multimodal image input supported?
A: Yes. Use a vision model, such as deepseek-v4-Vision, and include the image in messages:
messages = [{ "role": "user", "content": [ { "type": "text", "text": "What is shown in this image?" }, { "type": "image_url", "image_url": { "url": "https://example.com/photo.jpg" } } ]}]Images can be provided using either a URL or Base64 data.
Common image formats, such as JPEG and PNG, are supported.
Each request can contain up to one image.
Images consume input Tokens automatically based on their resolution.
Q: Is the Embeddings API supported?
A: Yes. It can be used for RAG retrieval, semantic search, and similar scenarios:
response = client.embeddings.create( model="[Model ID-Embed]", input=["Hello, world", "Hello World"]) print(response.data[0].embedding) # Vector arrayOutput dimensions:
[768 / 1024 / 1536], depending on the model.Batch input is supported, with up to 10 text entries per request.
Q: What is the Base URL?
A:
- Standard Base URL: https://api.maitoken.com/v1
