Using Anthropic Chat Completion
Request
URL: https://ai.purlabs.xyz/anthropic/chat/completions
Request Method: POST
TS Interface
interface Request {
model: string;
messages: {
role: 'user' | 'assistant' | 'system' | 'function';
content: string;
name?: string;
function_call?: object;
}[];
max_tokens_to_sample?: number;
temperature?: number;
top_p?: number;
top_k?: number;
};Example JSON Request Body
{
"model": "claude-instant-1",
"messages": [
{
"role": "user",
"content": "hey, who are you?"
},
{
"role": "assistant",
"content": "i'm your bro"
},
{
"role": "user",
"content": "oh hello my bro!"
}
]
}Response
TS Response Interface
interface Response {
id: string;
created: number;
model: string;
choices: [
{
index: number;
message: {
role: 'assistant',
content: string;
};
finish_reason: any;
}
];
};Example JSON Response
{
"id": "c20ccfc2db49ca08b17b0b47ddb29ea6bdb750beb7dc146f17fcfb94a9beaf56",
"object": "chat.completion",
"created": 1690391419,
"model": "claude-instant-1.1",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "hello there !"
},
"finish_reason": "stop_sequence"
}
]
}