Skip to main content
Creates a model response for the given chat conversation. This endpoint follows the Anthropic API specification and the requests are sent to AWS Bedrock Anthropic, Google Vertex Anthropic, or Anthropic’s own deployments, depending on the selected model.

Before You Start

  • API key: To use the API, create a personal API key or ask your workspace admin for a workspace API key with the Completion API scope.

Base URL

Dedicated deploymentsReplace api.langdock.com with <your-deployment-url>/api/public in all requests.

Parameters

Request bodies follow the Anthropic “Create a message” endpoint shape, with the following exceptions: From the anthropic-beta request header, Langdock forwards only fine-grained-tool-streaming-2025-05-14 and drops other comma-separated values. Bedrock receives the value in the request body as anthropic_beta. Anthropic receives it as the anthropic-beta header. Vertex routes omit it.

Prompt caching

Cache large, stable prompt parts such as system prompts and tool definitions across requests to reduce latency and input token cost. Add a cache_control marker with {"type": "ephemeral"} to the last block of the prompt section you want to cache:
  • cache_control is supported on system text blocks, on text, image, tool_use, and tool_result content blocks in messages, and on tool definitions in tools.
  • The system prompt must use the array of text blocks form. A plain string system value cannot carry a cache_control marker.
  • Only the block-level marker with {"type": "ephemeral"} is supported. Anthropic’s top-level automatic caching field and TTL options are not supported.
If the requested model resolves to a provider route without prompt caching support, requests containing cache_control markers return 400 Bad Request with the resolved route in the error message. Responses report cache activity in usage.cache_creation_input_tokens (tokens written to the cache) and usage.cache_read_input_tokens (tokens read from the cache). See the Anthropic prompt caching guide for caching strategy, minimum cacheable prompt lengths, and model support.

Rate limits

The default limits are 500 RPM (requests per minute) and 150,000 TPM (tokens per minute).
  • RPM is enforced per workspace, model, and API key.
  • TPM is shared by all API keys using the same model in a workspace.
  • On Langdock Cloud, admins can set TPM for custom models in Settings > Workspace > Products > API; it caps the estimated size of a single request.
  • On dedicated deployments, admins can configure custom limits per model in Settings > Workspace > Products > API.
If you exceed your rate limit, you will receive a 429 Too Many Requests response. Streaming requests (stream: true) stay open with keep-alive bytes while the model is slow to respond. If a non-streaming request does not complete within 105 seconds, you will receive 504 Gateway Timeout with {"message": "The model did not respond in time. Please retry."}.

Using Anthropic-compatible libraries

You can use popular libraries like the Anthropic Python library or the Vercel AI SDK against this endpoint. Send request bodies that match the Parameters section.

Example using the Anthropic Python library

Example using the Vercel AI SDK in Node.js

Langdock intentionally blocks browser-origin requests to protect your API key and ensure your applications remain secure. For more information, please see our guide on API Key Best Practices.