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

Stream a chat completion

Streams an assistant response by sending one or more user messages. Returns an NDJSON stream.

POST/v1/chat/completions/stream

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

curl -X POST "https://api.haufe.ai/agents/v1/chat/completions/stream" \  -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"  }'
{
  "created_at": "2025-03-15T09:13:02.654321Z",
  "delta": {
    "content": "Während der Probezeit beträgt die Kündigungsfrist ",
    "role": "assistant",
    "sources": []
  },
  "message_id": "5e6f7081-9012-def0-1234-556677889900",
  "thread_id": "1a2b3c4d-5678-9abc-def0-112233445566"
}

{
  "error_code": "assistant_not_available",
  "detail": "Assistant not available to your tenant"
}

{
  "error_code": "resource_not_found",
  "detail": "Resource not found"
}

{
  "error_code": "validation_error",
  "detail": [
    {
      "loc": [
        "body",
        "assistant_id"
      ],
      "message": "Field required",
      "type": "missing"
    }
  ]
}

{
  "error_code": "rate_limit_gateway",
  "detail": "Rate limit exceeded"
}

{
  "error_code": "api_timeout_error",
  "detail": "OpenAI API request timed out."
}

{
  "error_code": "internal_service_error",
  "detail": "An internal service required for processing the request is currently unavailable. Please try again later."
}