OpenAI API completions endpoint#
Note: This endpoint works only with LLM graphs.
API Reference#
OpenVINO Model Server includes now the completions
endpoint using OpenAI API.
Please see the OpenAI API Reference for more information on the API.
The endpoint is exposed via a path:
http://server_name:port/v3/completions
Example request#
curl http://localhost/v3/completions \
-H "Content-Type: application/json" \
-d '{
"model": "llama3",
"prompt": "This is a test",
"stream": false
}'
Example response#
{
"choices": [
{
"finish_reason": "stop",
"index": 0,
"logprobs": null,
"text": "You are testing me!"
}
],
"created": 1716825108,
"model": "llama3",
"object": "text_completion"
}
Request#
Generic#
Param |
OpenVINO Model Server |
OpenAI /completions API |
vLLM Serving Sampling Params |
Type |
Description |
---|---|---|---|---|---|
model |
✅ |
✅ |
✅ |
string (required) |
Name of the model to use. From administrator point of view it is the name assigned to a MediaPipe graph configured to schedule generation using desired model. |
stream |
✅ |
✅ |
✅ |
bool (optional, default: |
If set to true, partial message deltas will be sent to the client. The generation chunks will be sent as data-only server-sent events as they become available, with the stream terminated by a |
prompt |
⚠️ |
✅ |
✅ |
string or array (required) |
The prompt(s) to generate completions for, encoded as a string, array of strings, array of tokens, or array of token arrays. Limitations: only single string prompt is currently supported. |
max_tokens |
✅ |
✅ |
✅ |
integer |
The maximum number of tokens that can be generated. If not set, the generation will stop once |
ignore_eos |
✅ |
❌ |
✅ |
bool (default: |
Whether to ignore the |
Beam search sampling specific#
Param |
OpenVINO Model Server |
OpenAI /completions API |
vLLM Serving Sampling Params |
Type |
Description |
---|---|---|---|---|---|
n |
✅ |
✅ |
✅ |
integer (default: |
Number of output sequences to return for the given prompt. This value must be between |
best_of |
✅ |
✅ |
✅ |
integer (default: |
Number of output sequences that are generated from the prompt. From these best_of sequences, the top n sequences are returned. best_of must be greater than or equal to n. This is treated as the beam width for beam search sampling. |
diversity_penalty |
✅ |
❌ |
❌ |
float (default: |
This value is subtracted from a beam’s score if it generates the same token as any beam from other group at a particular time. See arXiv 1909.05858. |
length_penalty |
✅ |
❌ |
✅ |
float (default: |
Exponential penalty to the length that is used with beam-based generation. It is applied as an exponent to the sequence length, which in turn is used to divide the score of the sequence. Since the score is the log likelihood of the sequence (i.e. negative), |
Multinomial sampling specific#
Param |
OpenVINO Model Server |
OpenAI /completions API |
vLLM Serving Sampling Params |
Type |
Description |
---|---|---|---|---|---|
temperature |
✅ |
✅ |
✅ |
float (default: |
The value is used to modulate token probabilities for multinomial sampling. It enables multinomial sampling when set to |
top_p |
✅ |
✅ |
✅ |
float (default: |
Controls the cumulative probability of the top tokens to consider. Must be in (0, 1]. Set to 1 to consider all tokens. |
top_k |
✅ |
❌ |
✅ |
int (default: |
Controls the number of top tokens to consider. Set to 0 to consider all tokens. |
repetition_penalty |
✅ |
❌ |
✅ |
float (default: |
Penalizes new tokens based on whether they appear in the prompt and the generated text so far. Values > |
seed |
✅ |
✅ |
✅ |
integer (default: |
Random seed to use for the generation. |
Unsupported params from OpenAI service:#
echo
frequency_penalty
logit_bias
logprobs
presence_penalty
stop
stream_options
suffix
Unsupported params from vLLM:#
presence_penalty
frequency_penalty
min_p
use_beam_search (In OpenVINO Model Server just simply increase best_of param to enable beam search)
early_stopping
stop
stop_token_ids
include_stop_str_in_output
min_tokens
logprobs
prompt_logprobs
detokenize
skip_special_tokens
spaces_between_special_tokens
logits_processors
truncate_prompt_tokens
Response#
Param |
OpenVINO Model Server |
OpenAI /completions API |
Type |
Description |
---|---|---|---|---|
choices |
✅ |
✅ |
array |
A list of chat completion choices. Can be more than one if |
choices.index |
✅ |
✅ |
integer |
The index of the choice in the list of choices. |
choices.text |
✅ |
✅ |
string |
A chat completion text generated by the model. |
choices.finish_reason |
⚠️ |
✅ |
string or null |
The reason the model stopped generating tokens. This will be |
choices.logprobs |
❌ |
✅ |
object or null |
Log probability information for the choice. In current version, the logprobs is always null. |
created |
✅ |
✅ |
string |
The Unix timestamp (in seconds) of when the chat completion was created. |
model |
✅ |
✅ |
string |
The model used for the chat completion. |
object |
✅ |
✅ |
string |
always |
Unsupported params from OpenAI service:#
id
system_fingerprint
usage
References#
End to end demo with LLM model serving over OpenAI API
Developer guide for writing custom calculators with REST API extension