Generate legacy text completion from prompt
client.completions.create(CompletionCreateParamsbody, RequestOptionsoptions?): Completion { id, choices, created, 4 more } | Stream<Completion { id, choices, created, 4 more } >
POST/v5/completions
Generates a legacy text completion from a raw prompt (a string or list of strings).
Use this endpoint for non-chat, prompt-in/text-out inference using the OpenAI text-completion
contract; use /v5/chat/completions when you have a structured messages array, /v5/responses for
the OpenAI Responses API, and /v5/inference for payloads that follow no OpenAI schema. The model is
selected from model given as vendor/name and routed to the matching per-vendor gateway. When
stream is set the response is delivered as server-sent events; otherwise a single text_completion
object is returned. Token usage is recorded for the account, read from the final chunk on streaming
responses.
Generate legacy text completion from prompt
import SGPClient from 'scale-gp';
const client = new SGPClient({
accountID: 'My Account ID',
apiKey: process.env['SGP_API_KEY'], // This is the default and can be omitted
});
const completion = await client.completions.create({ model: 'model', prompt: 'string' });
console.log(completion.id);{
"id": "id",
"choices": [
{
"finish_reason": "stop",
"index": 0,
"text": "text",
"logprobs": {
"text_offset": [
0
],
"token_logprobs": [
0
],
"tokens": [
"string"
],
"top_logprobs": [
{
"foo": 0
}
]
}
}
],
"created": 0,
"model": "model",
"object": "text_completion",
"system_fingerprint": "system_fingerprint",
"usage": {
"completion_tokens": 0,
"prompt_tokens": 0,
"total_tokens": 0,
"completion_tokens_details": {
"accepted_prediction_tokens": 0,
"audio_tokens": 0,
"reasoning_tokens": 0,
"rejected_prediction_tokens": 0
},
"prompt_tokens_details": {
"audio_tokens": 0,
"cached_tokens": 0
}
}
}Returns Examples
{
"id": "id",
"choices": [
{
"finish_reason": "stop",
"index": 0,
"text": "text",
"logprobs": {
"text_offset": [
0
],
"token_logprobs": [
0
],
"tokens": [
"string"
],
"top_logprobs": [
{
"foo": 0
}
]
}
}
],
"created": 0,
"model": "model",
"object": "text_completion",
"system_fingerprint": "system_fingerprint",
"usage": {
"completion_tokens": 0,
"prompt_tokens": 0,
"total_tokens": 0,
"completion_tokens_details": {
"accepted_prediction_tokens": 0,
"audio_tokens": 0,
"reasoning_tokens": 0,
"rejected_prediction_tokens": 0
},
"prompt_tokens_details": {
"audio_tokens": 0,
"cached_tokens": 0
}
}
}