- 首页
- 文档
文档
Sakuranbo AI 是面向开发者的文本、图像和视频生成模型 API。一个目录、一种错误格式和一份预付 USD 余额即可覆盖所有模型。
使用 OpenAI SDK
章节标题“使用 OpenAI SDK”Sakuranbo AI 可以直接使用 OpenAI 的 SDK。如果你已有调用 OpenAI API 的代码,想要试用 Sakuranbo AI,只需把基础 URL 改为 https://api.sakuranbo.ai/v1,并把 API 密钥换成你的 Sakuranbo AI 密钥。model 请像示例中那样,填写 Sakuranbo AI 的模型 ID。
curl -X POST "https://api.sakuranbo.ai/v1/chat/completions" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $SAKURANBO_API_KEY" \ -d '{ "model": "sakuranbo/cherrytext-1.0-flash", "messages": [ { "role": "system", "content": "You are a concise assistant." }, { "role": "user", "content": "Summarize the benefits of prepaid API credits in two lines." } ], "max_tokens": 2048}'import OpenAI from "openai";
const apiKey = process.env.SAKURANBO_API_KEY;if (!apiKey) throw new Error("Set the SAKURANBO_API_KEY environment variable.");
const client = new OpenAI({ baseURL: "https://api.sakuranbo.ai/v1", apiKey,});
const completion = await client.chat.completions.create({ model: "sakuranbo/cherrytext-1.0-flash", messages: [ { role: "system", content: "You are a concise assistant." }, { role: "user", content: "Summarize the benefits of prepaid API credits in two lines." } ], max_tokens: 2048});
console.log(completion.choices[0]?.message.content);import os
from openai import OpenAI
client = OpenAI( base_url="https://api.sakuranbo.ai/v1", api_key=os.environ["SAKURANBO_API_KEY"],)
completion = client.chat.completions.create( model="sakuranbo/cherrytext-1.0-flash", messages=[ { "role": "system", "content": "You are a concise assistant.", }, { "role": "user", "content": "Summarize the benefits of prepaid API credits in two lines.", }, ], max_tokens=2048,)
print(completion.choices[0].message.content)TypeScript 和 Python 的示例使用官方的 OpenAI SDK。示例从环境变量 SAKURANBO_API_KEY 读取 API 密钥,并使用模型 sakuranbo/cherrytext-1.0-flash。创建密钥请参阅快速开始。Anthropic SDK 和对话的其他功能,请参阅对话。
开始使用
章节标题“开始使用”指南
章节标题“指南”- 对话:通过兼容 OpenAI 和兼容 Anthropic 的端点生成文本,支持流式输出。
- 图像:生成和编辑图像。
- 视频:根据文本、首帧或参考图像生成视频。
- 任务:跟踪、列出和取消图像与视频任务。
- Webhook:接收任务、充值和低余额事件,并验证其签名。
- 余额与 API 密钥限额:读取余额和 API 密钥的支出上限。
参考
章节标题“参考”- 模型 API:
GET /v1/models和GET /v1/models/{vendor}/{model}。 - 费用预估 API:
POST /v1/estimate。 - 错误:错误格式、HTTP 状态码和所有错误代码。
- 定价与计费:预付余额、充值、单价以及不计费的情形。
- MCP 服务器:通过编码代理搜索文档、查看模型、预估费用,并读取余额和历史记录。
面向工具和智能体
章节标题“面向工具和智能体”- OpenAPI 3.1 定义
- 交互式 API 参考
- llms.txt:面向 LLM 和智能体的简短索引。
所有价格均以 USD 计价,标价已包含我们的加价。