API 概述
OSP API 对外暴露统一接口,兼容 OpenAI API 格式,方便现有工具集成。
认证
所有请求必须在 Header 中携带 API Key:
Authorization: Bearer sk-xxxxxxxxxxxxxxxxBase 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 | 参数错误 |
401 | API Key 无效 |
403 | 无权限 |
429 | 频率限制,等3-5秒重试 |
500 | 服务器内部错误 |