API 文件
MeshTok 是 100% 相容 OpenAI 的閘道器。如果您的程式碼已能呼叫 OpenAI,只需更改兩項設定:base URL 和您的 API 金鑰。
1. 取得您的 API 金鑰
Sign in to the 控制台 and create a token. Your key looks like sk-xxxx....
2. Base URL
相容 OpenAI(建議使用)
https://meshtok.com/v1 Use with OpenAI SDK, Cursor, Cline, Aider, and most tools. Covers all 175 models.
相容 Anthropic
https://meshtok.com Use with Claude Code, Anthropic SDK, and tools that require the Anthropic Messages API format.
Most users only need the OpenAI-compatible endpoint. All endpoints follow the OpenAI convention: /v1/chat/completions, /v1/models, /v1/embeddings.
3. Python 範例
# pip install openai from openai import OpenAI client = OpenAI( base_url="https://meshtok.com/v1", api_key="sk-your-MeshTok-key", ) # any of 175 models -same code, just change the model name resp = client.chat.completions.create( model="deepseek/deepseek-v4-pro", messages=[{"role":"user","content":"Explain quantum computing in one sentence."}], ) print(resp.choices[0].message.content)
4. JavaScript 範例
// npm install openai import OpenAI from "openai"; const client = new OpenAI({ baseURL: "https://meshtok.com/v1", apiKey: "sk-your-MeshTok-key", }); const resp = await client.chat.completions.create({ model: "bigmodel/glm-5.2", messages: [{ role: "user", content: "Hello!" }], }); console.log(resp.choices[0].message.content);
5. 串流
Add stream: true for Server-Sent Events streaming, identical to OpenAI's format.
curl https://meshtok.com/v1/chat/completions \ -H "Authorization: Bearer sk-your-MeshTok-key" \ -H "Content-Type: application/json" \ -d '{"model":"anthropic/claude-sonnet-5","messages":[{"role":"user","content":"Hi"}],"stream":true}'
6. 列出所有模型
curl https://meshtok.com/v1/models \
-H "Authorization: Bearer sk-your-MeshTok-key" Returns the full list of 175 available model IDs. Browse them visually on the models page.
功能指南
串流回應 →
以 OpenAI 格式傳送的伺服器推送事件。包含 Python、JS 及原始 SSE 解析。
工具與函式呼叫 →
讓 154 個模型呼叫您的函式。完整的代理循環與並行呼叫。
結構化輸出 →
強制輸出有效 JSON。支援 json_object 與嚴格的 json_schema 模式。
視覺與圖片輸入 →
傳送圖片給 58 個視覺模型。支援網址、base64、OCR 及多圖片。
模型備援 →
跨實驗室自動容錯轉移。支援循序與並行模式。
程式碼代理與 IDE →
Claude Code、Cursor、Cline、Aider、Continue、Codex 設定。
多模態輸入 →
圖片、音訊、影片、PDF — 支援 69 個多模態模型。
準備好開始建構了嗎? 取得 API 金鑰