Skip to content

API 概述 ​

OSP API 对外暴露统一接口,兼容 OpenAI API 格式,方便现有工具集成。


认证 ​

所有请求必须在 Header 中携带 API Key:

Authorization: Bearer sk-xxxxxxxxxxxxxxxx

Base URL ​

https://api.osp.io

支持的端点 ​

对话补全 /v1/chat/completions ​

json
POST /v1/chat/completions
{
  "model": "gpt-4",
  "messages": [{"role": "user", "content": "Hello"}]
}

文本补全 /v1/completions ​

json
POST /v1/completions
{
  "model": "gpt-3.5-turbo-instruct",
  "prompt": "The capital of France is"
}

图片生成 /v1/images/generations ​

json
POST /v1/images/generations
{
  "model": "dall-e-3",
  "prompt": "A cute baby sea otter",
  "size": "1024x1024"
}

文本嵌入 /v1/embeddings ​

json
POST /v1/embeddings
{
  "model": "text-embedding-3-small",
  "input": "The food was delicious"
}

模型列表 /v1/models ​

json
GET /v1/models

错误处理 ​

状态码说明
200成功
400参数错误
401API Key 无效
403无权限
429频率限制,等3-5秒重试
500服务器内部错误