🚀 Simplify your work by integrating Haufe Copilot via API
Chat Completions

Create a chat completion

Returns an assistant response by sending one or more user messages. Does not stream the response.

POST/v1/chat/completions

Authorization

APIKeyHeader
api-key<token>

In: header

Query Parameters

thread_id?|null

Request Body

application/json

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "https://example.com/v1/chat/completions" \  -H "Content-Type: application/json" \  -d '{    "assistant_id": "a1b2c3d4-5678-9abc-def0-1234567890ab",    "messages": [      {        "content": "Welche Kündigungsfristen gelten während der Probezeit?",        "role": "user"      }    ],    "user_id": "f8e7d6c5-4321-fedc-ba98-765432109876"  }'
{
  "content": "Während der Probezeit beträgt die Kündigungsfrist gemäß § 622 Abs. 3 BGB zwei Wochen. Diese Frist gilt für beide Seiten.",
  "created_at": "2025-03-15T09:13:02.654321Z",
  "id": "5e6f7081-9012-def0-1234-556677889900",
  "meta_data": {
    "intent": "Kündigungsfrist Probezeit",
    "legal_advice": false,
    "type": "53aa66b7-b874-407f-967c-3a959c919d62"
  },
  "role": "assistant",
  "sources": [
    {
      "content": "§ 622 Abs. 3 BGB: Während einer vereinbarten Probezeit, längstens für die Dauer von sechs Monaten, kann das Arbeitsverhältnis mit einer Frist von zwei Wochen gekündigt werden.",
      "meta_data": {
        "document_title": "Bürgerliches Gesetzbuch (BGB)",
        "section": "§ 622 Abs. 3"
      }
    }
  ],
  "thread_id": "1a2b3c4d-5678-9abc-def0-112233445566"
}

{
  "error_code": "incorrect_stack_ending",
  "detail": "The last message in the stack must be a user, tool, or system message."
}

{
  "error_code": "unauthorized",
  "detail": "Missing or invalid API key"
}
{
  "error_code": "attachment_access_forbidden",
  "detail": "You do not have permission to access this attachment."
}
{
  "error_code": "assistant_not_found",
  "detail": "Assistant not found"
}

{
  "error_code": "conflict",
  "detail": "Conflict - File is infected with a virus or it's still being processed"
}

{
  "error_code": "attachment_not_unique",
  "detail": "A thread can contain only a single attachment."
}

{
  "message": "Rate limit exceeded!"
}

{
  "error_code": "internal_server_error",
  "detail": "Internal Server Error"
}
{
  "error_code": "attachment_document_not_reachable",
  "detail": "The file attachment service does not respond as expected. Please try again later."
}
{
  "error_code": "internal_service_error",
  "detail": "An internal service required for processing the request is currently unavailable. Please try again later."
}