客户端 SDK
我们提供 Python 和 Typescript 库,使 API 的使用变得更加容易。
Python
例子:
from anthropic import Anthropic, HUMAN_PROMPT, AI_PROMPT
anthropic = Anthropic()
completion = anthropic.completions.create(
model="claude-2",
max_tokens_to_sample=300,
prompt=f"{HUMAN_PROMPT} How many toes do dogs have?{AI_PROMPT}",
)
print(completion.completion)
Typescript
例子:
import Anthropic from '@anthropic-ai/sdk';
const anthropic = new Anthropic();
async function main() {
const completion = await anthropic.completions.create({
model: 'claude-2',
max_tokens_to_sample: 300,
prompt: `${HUMAN_PROMPT} How many toes do dogs have?${AI_PROMPT}`,
});
console.log(completion.completion);
}
main().catch(console.error);
最后修改时间: 1 年前