cURL(通用)
用 cURL 跑通各接口,方便快速验证和排障。先把 Key 放进环境变量:
bash
export TT_API_KEY="sk-你的key"示例使用网关地址 https://gateway.mindproxy.ai。
Chat(OpenAI 兼容)
bash
curl https://gateway.mindproxy.ai/v1/chat/completions \
-H "Authorization: Bearer $TT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o-mini",
"messages": [{"role": "user", "content": "你好"}]
}'流式输出加 "stream": true:
bash
curl https://gateway.mindproxy.ai/v1/chat/completions \
-H "Authorization: Bearer $TT_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "gpt-4o-mini", "stream": true,
"messages": [{"role": "user", "content": "讲个笑话"}]}'Claude 原生(Anthropic Messages)
bash
curl https://gateway.mindproxy.ai/v1/messages \
-H "x-api-key: $TT_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-3-5-sonnet",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "你好"}]
}'也接受 Authorization: Bearer $TT_API_KEY。
Gemini 原生(generateContent)
bash
curl "https://gateway.mindproxy.ai/v1beta/models/gemini-1.5-pro:generateContent?key=$TT_API_KEY" \
-H "Content-Type: application/json" \
-d '{"contents": [{"parts": [{"text": "你好"}]}]}'流式用 :streamGenerateContent。
Embeddings
bash
curl https://gateway.mindproxy.ai/v1/embeddings \
-H "Authorization: Bearer $TT_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "text-embedding-3-small", "input": "一段文本"}'图像生成
bash
curl https://gateway.mindproxy.ai/v1/images/generations \
-H "Authorization: Bearer $TT_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "gpt-image-1", "prompt": "夜晚的城市", "n": 1, "size": "1024x1024"}'按实际返回的图片数量计费。详见 图像生成。
列出可用模型
bash
curl https://gateway.mindproxy.ai/v1/models \
-H "Authorization: Bearer $TT_API_KEY"常用调试技巧
- 看响应头:加
-i(或-D -)打印响应头,里面有X-TT-Request-ID,排障时提供给客服即可定位。 - 试运行(不真正发起生成、不扣费):加
-H "X-TT-Dry-Run: true",只做鉴权和计费预冻结,返回计费预估。 - 幂等:重试同一请求时带
-H "Idempotency-Key: <你的唯一key>",避免重复扣费。