v9

latestOpenAPI 3.1.0raw.githubusercontent.com2024-08-3023155.5 KB
text

Create Chat Completion

Create a Chat Completion.

post/v1/chat/completions

Request body

frequency_penaltynumber

Penalizes new tokens based on their frequency in the generated text so far.

ignore_eosboolean

Whether to ignore the EOS token and continue generating tokens after the EOS token is generated.

log_promptboolean

OctoAI stores request prompt if True.

logit_biasobject nullable

Modify the likelihood of specified tokens appearing in the completion. Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. As an example, you can pass {'50256': -100} to prevent the <|endoftext|> token from being generated.

loglikelihoodboolean

Return log probabilities for all prompt tokens excluding the first one from prefill step if True.

logprobsboolean

Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the content of message.

max_tokensinteger

Maximum number of tokens to generate per output sequence.

min_pnumber

Sets a dynamic threshold of the top tokens to consider based on the probability value of the most likely next token. Following https://arxiv.org/abs/2407.01082.

modelstring required

The identifier of the model to use. Can be a shared tenancy or custom model identifier.

ninteger

Number of output sequences to return.

peftstring nullable

Parameter-efficient fine-tuning ID.

presence_penaltynumber

Penalizes new tokens based on whether they appear in the generated text so far.

repetition_penaltynumber

Controls the likelihood of the model generating repeated texts.

streamboolean

If set, tokens will be streamed incrementally to users. One or more tokens will be sent as server-sent events (SSE) as they become available. For more information on read above.

temperaturenumber

Controls the randomness of the sampling.

top_logprobsinteger

An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. logprobs must be set to true if this parameter is used.

top_pnumber

Controls the cumulative probability of the top tokens to consider.

userstring nullable

A unique identifier representing your end-user.

Example request

{
  "max_tokens": 128,
  "messages": [
    {
      "content": "You are a helpful assistant. Keep your responses limited to one short paragraph if possible.",
      "role": "system"
    },
    {
      "content": "Hello world",
      "role": "user"
    }
  ],
  "model": "llama-2-13b-chat-fp16",
  "temperature": 0.1,
  "top_p": 0.9
}

Response

An OctoAI text endpoint can be requested in either a synchronous orstreaming mode.When the request body has stream: False set the content type will beapplication/json. When the request body has stream: True set thecontent type will be text-event-stream and will respond with a stream ofserver-send-events (SSE).

createdinteger required

The Unix timestamp (in seconds) of when the chat completion was created.

idstring required

A unique identifier for the chat completion.

modelstring required

The model used for the chat completion.

object'chat.completion'

Object type field which is a constant and preset.

Example response

{
  "choices": [],
  "created": 11,
  "id": "chat-cmpl-123",
  "model": "my_model",
  "usage": {
    "completion_tokens": 20,
    "prompt_tokens": 10,
    "total_tokens": 30
  }
}
All 2 operations