import SGPClient from 'sgp';
const client = new SGPClient({
apiKey: 'My API Key',
});
const completion = await client.beta.chat.completions.create({ messages: [{ foo: 'bar' }], model: 'model' });
console.log(completion);
{
"id": "<string>",
"object": "chat.completion",
"choices": [
{
"finish_reason": "stop",
"index": 123,
"logprobs": {
"content": [
{
"token": "<string>",
"bytes": [
123
],
"logprob": 123,
"top_logprobs": [
{
"token": "<string>",
"bytes": [
123
],
"logprob": 123
}
]
}
],
"refusal": [
{
"token": "<string>",
"bytes": [
123
],
"logprob": 123,
"top_logprobs": [
{
"token": "<string>",
"bytes": [
123
],
"logprob": 123
}
]
}
]
},
"message": {
"content": "<string>",
"refusal": "<string>",
"role": "assistant",
"annotations": [
{
"type": "url_citation",
"url_citation": {
"end_index": 123,
"start_index": 123,
"title": "<string>",
"url": "<string>"
}
}
],
"audio": {
"id": "<string>",
"data": "<string>",
"expires_at": 123,
"transcript": "<string>"
},
"function_call": {
"arguments": "<string>",
"name": "<string>"
},
"tool_calls": [
{
"id": "<string>",
"function": {
"arguments": "<string>",
"name": "<string>"
},
"type": "function"
}
]
}
}
],
"created": 123,
"model": "<string>",
"service_tier": "auto",
"system_fingerprint": "<string>",
"usage": {
"completion_tokens": 123,
"prompt_tokens": 123,
"total_tokens": 123,
"completion_tokens_details": {
"accepted_prediction_tokens": 123,
"audio_tokens": 123,
"reasoning_tokens": 123,
"rejected_prediction_tokens": 123
},
"prompt_tokens_details": {
"audio_tokens": 123,
"cached_tokens": 123
}
}
}
import SGPClient from 'sgp';
const client = new SGPClient({
apiKey: 'My API Key',
});
const completion = await client.beta.chat.completions.create({ messages: [{ foo: 'bar' }], model: 'model' });
console.log(completion);
{
"id": "<string>",
"object": "chat.completion",
"choices": [
{
"finish_reason": "stop",
"index": 123,
"logprobs": {
"content": [
{
"token": "<string>",
"bytes": [
123
],
"logprob": 123,
"top_logprobs": [
{
"token": "<string>",
"bytes": [
123
],
"logprob": 123
}
]
}
],
"refusal": [
{
"token": "<string>",
"bytes": [
123
],
"logprob": 123,
"top_logprobs": [
{
"token": "<string>",
"bytes": [
123
],
"logprob": 123
}
]
}
]
},
"message": {
"content": "<string>",
"refusal": "<string>",
"role": "assistant",
"annotations": [
{
"type": "url_citation",
"url_citation": {
"end_index": 123,
"start_index": 123,
"title": "<string>",
"url": "<string>"
}
}
],
"audio": {
"id": "<string>",
"data": "<string>",
"expires_at": 123,
"transcript": "<string>"
},
"function_call": {
"arguments": "<string>",
"name": "<string>"
},
"tool_calls": [
{
"id": "<string>",
"function": {
"arguments": "<string>",
"name": "<string>"
},
"type": "function"
}
]
}
}
],
"created": 123,
"model": "<string>",
"service_tier": "auto",
"system_fingerprint": "<string>",
"usage": {
"completion_tokens": 123,
"prompt_tokens": 123,
"total_tokens": 123,
"completion_tokens_details": {
"accepted_prediction_tokens": 123,
"audio_tokens": 123,
"reasoning_tokens": 123,
"rejected_prediction_tokens": 123
},
"prompt_tokens_details": {
"audio_tokens": 123,
"cached_tokens": 123
}
}
}
Successful Response
The response is of type object
.