POST
/
v4
/
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 completionsResponse = await client.completions.create({ model: 'gpt-4', prompt: 'prompt' });

  console.log(completionsResponse.completion);
}

main();
{
  "completion": {
    "text": "<string>",
    "finish_reason": "<string>",
    "response_metadata": {}
  },
  "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.