Chat

Create Chat Completion

This endpoint is compatible with the OpenAI library. If certain parameters are not supported by the OpenAI library, they can be provided in the extra_body field of the OpenAI request.<br/>When creating the OpenAI object, set the base_url as the API domain followed by /v1.

post/v1/chat/completions

Request

  • Base URL: https://api.fanar.qa (the document declares no server; this is the origin it was published from)
  • URL: https://api.fanar.qa/v1/chat/completions
  • Auth: HTTP bearer

Request body

model'Fanar' | 'Fanar-S-1-7B' | 'Fanar-C-1-8.7B' | 'Fanar-C-2-27B' | 'Fanar-Sadiq' | 'Fanar-Sadiq-2' | 'Fanar-Oryx-IVU-2' required
enable_thinkingboolean nullable

Whether to enable the thinking role in the conversation. This only applies if the model supports it. Currently, only the Fanar-C-2-27B model supports this parameter with additional authorization.

frequency_penaltynumber nullable

A penalty for how much new tokens should avoid repeating existing ones.

logit_biasobject nullable

Modify the likelihood of specified tokens appearing in the completion.

logprobsboolean nullable

Whether to return log probabilities of the output tokens or not.

top_logprobsinteger nullable

An integer between 0 and 20 specifying the number of most likely tokens toreturn at each token position, each with an associated log probability.

max_tokensinteger nullable

The maximum number of tokens that can be generated in the chat completion.

ninteger nullable

How many chat completion choices to generate for each input message.

presence_penaltynumber nullable

Number between -2.0 and 2.0. Positive values penalize new tokens based onwhether they appear in the text so far, increasing the model's likelihood totalk about new topics.

streamboolean nullable

Whether to stream back partial progress as tokens are generated.

temperaturenumber nullable

The sampling temperature, where 0.0 means deterministic output.

top_pnumber nullable

Controls the cumulative probability of the top tokens to consider.

best_ofinteger nullable

Number of output sequences that are generated from the prompt.

top_kinteger nullable

Controls the number of top tokens to consider.

min_pnumber nullable

Represents the minimum probability for a token to be considered, relative to the probability of the most likely token.

repetition_penaltynumber nullable

A penalty for repeating the same tokens in the generated output.

length_penaltynumber nullable

Penalizes sequences based on their length. Used in beam search.

early_stoppingboolean nullable

Controls the stopping condition for beam-based methods.

stop_token_idsinteger[] nullable

List of tokens that stop the generation when they are generated.

ignore_eosboolean nullable

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

min_tokensinteger nullable

Minimum number of tokens to generate per output sequence before EOS or stop_token_ids can be generated.

skip_special_tokensboolean nullable

Whether to skip special tokens in the output.

spaces_between_special_tokensboolean nullable

Whether to add spaces between special tokens in the output.

truncate_prompt_tokensinteger nullable

If set to an integer k, will use only the last k tokens from the prompt

prompt_logprobsinteger nullable

Number of log probabilities to return per prompt token.

book_namesBookNamesEnum[] nullable

List of book names to use for the Fanar-Sadiq model.

madhabMadhabEnum[] nullable

List of madhab (Islamic school of thought) to filter by for the Fanar-Sadiq-2 model.

restrict_to_islamicboolean nullable

When enabled for Fanar-Sadiq model, only Islamic content prompts will be accepted. Non-Islamic content will be rejected.

personastring nullable

Custom persona that controls the assistant's voice and identity for the Fanar-Sadiq model. Free-form text; only supported for Fanar-Sadiq.

Example request

{
  "model": "Fanar",
  "messages": [
    {
      "role": "user",
      "content": "Hello"
    }
  ]
}

Response

Chat completion response

idstring required

A unique identifier for the chat completion

createdinteger required

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

modelstring required

The model used for the chat completion.

object'chat.completion'

The object type

metadataobject nullable

Additional metadata associated with the completion.

Changes

No recorded changes to this operation across all 1 revision of this API.