Completions
Create chat completion
post/v1/chat/completions
Request
- Base URLhttps://api.us-east-1.langdb.ai
- AuthHTTP bearer
- TypeScriptA function with typed inputs. Its response is checked against the schema.
Headers
X-Project-Idstring required
LangDB project ID
Request body
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
Example response
{
"service_tier": "scale"
}Changes
No recorded changes to this operation across all 1 revision of this API.