Skip to content

开发者指南

聊天接口

bash
curl https://api.api2gpt.com/v1/chat/completions \
    -H 'Content-Type: application/json' \
    -H 'Authorization: Bearer YOUR_AK' \
    -d '{
    "model": "gpt-3.5-turbo",
    "messages": [{"role": "user", "content": "Hello!"}]
    }'

内容补全接口

bash
curl https://api.api2gpt.com/v1/completions \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_AK' \
  -d '{
  "model": "text-davinci-003",
  "prompt": "以我是小爱开头,补全一篇二百字的文章"
}'

文本转向量 Embeddings

bash
curl https://api.api2gpt.com/v1/embeddings \
  -X POST \
  -H "Authorization: Bearer YOUR_AK" \
  -H "Content-Type: application/json" \
  -d '{"input": "The food was delicious and the waiter...",
       "model": "text-embedding-ada-002"}'

文本编辑

bash
curl https://api.api2gpt.com/v1/edits \
  -X POST \
  -H "Authorization: Bearer YOUR_AK" \
  -H "Content-Type: application/json" \
  -d '{"input": "What qq is it",
       "n": 1,
       "model": "text-davinci-edit-001",
       "instruction": "请修改文本中的拼写错误"}'

图片生成

bash
curl https://api.api2gpt.com/v1/images/generations \
  -X POST \
  -H "Authorization: Bearer YOUR_AK" \
  -H "Content-Type: application/json" \
  -d '{"prompt": "生成一张可爱猫猫图",
       "n": 1,
       "model": "dall-e-3",
       "size": "1024x1024"}'

API文档与在线调试 访问

其它支持接口请参考 模型列表

错误码

错误原因状态码错误码
未提供 Key40140001
Key 错误(注意是 AK 开头的)40140002
用户不存在40140003
用户状态异常40140004
余额不足40240201
暂未开放的访问路径40340301
参数中没有提供模型参数40340302
参数中提供的模型参数暂未开放40340302
您的账户请求次数过多,超过分钟配额42942901

频率限制

每个key每分钟 60 个请求,如有特殊需求,可与客服联系

Powered by vitepress