完整的使用指南和代码示例
Dphn2Api 是一个为 Dolphin AI 提供 OpenAI 兼容 API 接口的代理服务器。
基础 URL
https://dphn2api.deno.dev/v1
所有 API 请求都需要在请求头中包含 Bearer Token:
Authorization: Bearer sk-dphn-key
/v1/models
获取可用模型列表
curl https://dphn2api.deno.dev/v1/models \ -H "Authorization: Bearer sk-dphn-key"
/v1/chat/completions
创建聊天完成(支持流式和非流式)
model
string, 必需 - 模型名称 (如 "Dolphin 24B")
messages
array, 必需 - 消息列表
stream
boolean, 可选 - 是否流式响应(默认: true)
curl -X POST https://dphn2api.deno.dev/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer sk-dphn-key" \ -d '{ "model": "Dolphin 24B", "messages": [ {"role": "user", "content": "你好"} ], "stream": false }'
Dolphin AI 支持以下模板类型(通过环境变量 DPHN_DEFAULT_TEMPLATE 配置):
logical
逻辑推理(默认)
summary
内容总结
code-beginner
代码入门
code-advanced
高级编程
from openai import OpenAI client = OpenAI( api_key="sk-dphn-key", base_url="https://dphn2api.deno.dev/v1" ) response = client.chat.completions.create( model="Dolphin 24B", messages=[{"role": "user", "content": "Hello!"}] ) print(response.choices[0].message.content)
import OpenAI from 'openai'; const client = new OpenAI({ apiKey: 'sk-dphn-key', baseURL: 'https://dphn2api.deno.dev/v1' }); const response = await client.chat.completions.create({ model: 'Dolphin 24B', messages: [{ role: 'user', content: 'Hello!' }] }); console.log(response.choices[0].message.content);