Completions

Create chat completion

post/v1/chat/completions

Request

Headers

X-Project-Idstring required

LangDB project ID

Request body

modelstring required

ID of the model to use. This can be either a specific model ID or a virtual model identifier.

temperaturenumber

Sampling temperature.

Example request

{
  "model": "gpt-4o",
  "messages": [
    {
      "role": "user",
      "content": "Write a haiku about recursion in programming."
    }
  ],
  "temperature": 0.8,
  "max_tokens": 1000,
  "top_p": 0.9,
  "frequency_penalty": 0.1,
  "presence_penalty": 0.2,
  "stream": false,
  "response_format": "json_object",
  "mcp_servers": [
    {
      "name": "websearch",
      "type": "in-memory"
    }
  ],
  "router": {
    "name": "kg_random_router",
    "type": "script",
    "script": "const route = ({ request, headers, models, metrics }) => { return {model: 'test'};};"
  },
  "extra": {
    "guards": [
      "word_count_validator_bd4bdnun",
      "toxicity_detection_4yj4cdvu"
    ],
    "user": {
      "id": "7",
      "name": "mrunmay",
      "tags": [
        "coding",
        "software"
      ]
    }
  }
}

Response

OK

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.

service_tier'scale' | 'default' nullable

The service tier used for processing the request. This field is only included if the service_tier parameter is specified in the request.

system_fingerprintstring

This fingerprint represents the backend configuration that the model runs with.

Can be used in conjunction with the seed request parameter to understand when backend changes have been made that might impact determinism.

object'chat.completion' required

The object type, which is always chat.completion.

Example response

{
  "service_tier": "scale"
}

Changes

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