UCloud logo UCloud logo UCloud
v2026.7.0-k8s.18
  1. UCloud/Core
  2. 1. Introduction
  3. 2. Projects
  4. 3. API Tokens
    1. 3.1. Platform API Tokens
    2. 3.2. Provider API Tokens
  5. 4. Accounting
  6. 5. Orchestration
  7. 6. Frontend
  8. UCloud/IM for Slurm-based HPC
  9. 7. Installation
  10. 8. Architecture and Networking
  11. 9. User and Project Management
  12. 10. Filesystem Integration
    1. 10.1. Inter-provider file transfers
  13. 11. Slurm Integration
    1. 11.1. Application Management
    2. 11.2. Built-in Applications
  14. 12. Reference
    1. 12.1. Configuration
    2. 12.2. CLI
  15. 13. Appendix
    1. 13.1. Built-in Application Index
  16. UCloud/IM for Kubernetes
  17. 14. Installation
  18. 15. Architecture and Networking
  19. 16. Filesystem Integration
  20. 17. Compute Jobs
    1. 17.1. Networks
    2. 17.2. Public Links
    3. 17.3. Public IPs
    4. 17.4. License Servers
    5. 17.5. SSH Servers
    6. 17.6. Job Audit Log
    7. 17.7. Virtual machines
  21. 18. AI Inference
    1. 18.1. Architecture
    2. 18.2. Chat Middleware
    3. 18.3. Chat Playground
    4. 18.4. Model Discovery and Catalog
    5. 18.5. Dynamo Deployments
    6. 18.6. Usage and Accounting
    7. 18.7. Audit
    8. 18.8. Metrics
    9. 18.9. Security
  22. 19. Integrated applications
    1. 19.1. Syncthing
    2. 19.2. Integrated terminal
    3. 19.3. Kubernetes clusters
      1. 19.3.1. Architecture
      2. 19.3.2. Stacks
      3. 19.3.3. Creating a cluster
      4. 19.3.4. Cluster dashboard
      5. 19.3.5. Networking and storage
      6. 19.3.6. Maintenance and upgrades
      7. 19.3.7. Backup and recovery
      8. 19.3.8. Reference
  23. 20. UCX applications
    1. 20.1. Hello world
    2. 20.2. Data binding
    3. 20.3. UI events
    4. 20.4. Component reference
    5. 20.5. API reference
  24. 21. Reference
    1. 21.1. Configuration
    2. 21.2. CLI
  25. Style guidelines
  26. 22. Branding and identity for UCloud
  27. 23. Documentation
  28. H: Procedures
  29. 24. H: Procedures
  30. 25. H: Introduction
  31. 26. H: Auditing
  32. 27. H: Auditing scenario
  33. 28. H: GitHub actions
  34. 29. H: Deployment
  35. 30. H: 3rd party dependencies (risk assesment)
  36. Glossary
  37. 31. Glossary
  1. Links
  2. Source Code
  3. Releases

Chat Middleware

The chat middleware serves the Chat Completions API, and it serves the chat call of the playground. The responses adapter serves the Responses API. Both live in the Integration Module, and both share the same authentication, catalog lookup, admission control, usage reporting, and audit records. See Request lifecycle.

The routes of the two parts are in the Public surface. The chat playground also reaches the chat middleware, and the responses adapter sends a chat call to it for every response.

flowchart TB
    clients["Clients<br/>OpenAI clients and the playground"]:::diagram-external-user-group

    subgraph im["UCloud/IM"]
        middleware["Middleware<br/>Chat | /v1/chat/completions"]:::diagram-provider-cog-6-tooth
        adapter["Adapter<br/>Responses | /v1/responses"]:::diagram-provider-cog-6-tooth
        catalog["Database<br/>Model catalog"]:::diagram-provider-circle-stack
        state["Filesystem<br/>Response state"]:::diagram-provider-folder
    end

    backend["Backend server<br/>OpenAI compatible"]:::diagram-provider-server

    class im diagram-provider-ucloud

    clients --> middleware
    clients --> adapter
    adapter --> middleware
    middleware --> catalog
    adapter --> state
    middleware --> backend

Which component serves which API, and what each part owns. The responses adapter sends its calls through the chat middleware. It does not show the order of the steps inside a call.

Chat middleware

The middleware validates the options of the request against the model, and it rejects an option that the model does not allow.

The middleware forwards the fields that the OpenAI-compatible APIs define, and it drops a field that it does not know. It replaces the requested model name with the name that the backend expects (endpoint.backendModelName). The endpoint must also follow the rules of the provider. See Backends.

The middleware relays the stream of the backend to the client without a change, including the deltas of tool calls. It switches on stream_options.include_usage, so that the backend reports the token usage at the end of a stream.

When the client cancels a request, the middleware charges nothing before it has called the backend. After the call, it reports an estimate: the input text of the request, and the output text that the client has already received, or the running time at 50 tokens per second. A request that a user cancels while it waits for capacity receives the status 499.

The middleware reports the usage that the backend sends with a successful answer. When the usage is absent, the request receives the reason success_missing_usage, and the middleware writes a warning at most once a minute for the model.

Upstream limits

LimitValue
Request body16 MB
Response header from the backend4 minutes
A stream without data2 minutes
Dial and connection setup10 seconds
Body of an upstream JSON answer8 MB
One event of an upstream stream8 MB
Write of one event to the client30 seconds

Responses adapter

The adapter holds a response as a small state machine: a response starts as queued, becomes in_progress while the model answers, and ends as completed or as failed. A response stores its state by default. See Storage for the files.

A conversation is an ordered list of items: the input items and the output items of every turn. Each turn rewrites the conversation file.

The adapter continues an earlier turn in one of two ways:

RequestResult
previous_response_idThe new response continues from the stored context of that response.
conversationThe new response continues the whole conversation.
Neither of the twoThe adapter starts a new conversation.

A request that points at state which the platform no longer holds fails with 404.

The adapter reports the state of a response as a stream of events: response.created, response.in_progress, response.output_item.added, response.content_part.added, response.output_text.delta, response.reasoning_text.delta, and response.function_call_arguments.delta, each with a matching *.done event. A custom tool call reports response.custom_tool_call_input.delta and closes with response.output_item.done. The stream ends with response.completed or response.failed.

A cancel request answers with the current state of the response, as a read does. A background response that does not survive a restart becomes failed.

The adapter writes one audit record for one logical call, and it suppresses the record of the chat call inside it. Deleting a response writes inference.responses.delete, and deleting a conversation writes inference.conversations.delete. See Audit.

Previous Architecture
Next Chat Playground