兼容官方 SDK
npm install @anthropic-ai/sdk1'use client'
2import Anthropic from '@anthropic-ai/sdk';
3const anthropic = new Anthropic({
4 baseURL: 'https://{系统分配的地址}/api/anthropic',
5 apiKey: "sk-ant-oneoh-******************",
6});
7
8async function main() {
9 const stream = anthropic.messages
10 .stream({
11 model: 'claude-3-5-sonnet-latest',
12 max_tokens: 1024,
13 messages: [
14 {
15 role: 'user',
16 content: '如何在 debian 12 将 443 和 80 端口全部转发到 1.1.1.1 上,包括 udp 和 tcp',
17 },
18 ],
19 })
20 .on('text', (text:any) => {
21 console.log(text);
22 });
23
24 const message = await stream.finalMessage();
25 console.log(message);
26}已兼容的 API 列表
以下 API 可适用绝大数场景,如果您希望使用其他官方 API,请邮件联系 support@oneoh.cloud
| API | 兼容性 | 支持 |
|---|---|---|
| /v1/messages | 99.9999% | yes |
| /v1/models | 99.9999% | yes |