POST
/
v4
/
chat-completions
import SGPClient from 'sgp';

const client = new SGPClient({
  apiKey: process.env['SGP_API_KEY'], // This is the default and can be omitted
});

async function main() {
  const chatCompletionsResponse = await client.chatCompletions.create({
    messages: [{ content: 'string' }],
    model: 'o1',
  });

  console.log(chatCompletionsResponse.chat_completion);
}

main();
{
  "chat_completion": {
    "message": {
      "role": "user",
      "content": "<string>"
    },
    "finish_reason": "<string>"
  },
  "token_usage": {
    "prompt": 123,
    "completion": 123,
    "total": 123
  }
}

Authorizations

x-api-key
string
header
required

Body

application/json

Response

200
application/json

Successful Response

The response is of type object.