Endpoints
Chat Completions API
API endpoints for generating chat completions
Chat Completions API
The Chat Completions API allows you to generate text responses using the Routstr platform’s proxy to OpenRouter.ai.
Base URL
Endpoints
Create Chat Completion
Generate a completion for the provided messages and parameters.
Request Body
Parameter | Type | Description |
---|---|---|
model | string | ID of the model to use (e.g., “gpt-4”) |
messages | array | Array of message objects with role and content |
max_tokens | integer | Maximum number of tokens to generate |
temperature | number | Sampling temperature (0-2) |
stream | boolean | Whether to stream the response |
Example Request
Example Response
Streaming Response
To receive a streaming response, set stream: true
in your request body:
The API will then return a stream of server-sent events, each containing a delta of the response.
Error Handling
Status Code | Description |
---|---|
400 | Bad Request - Check your request parameters |
401 | Unauthorized - Invalid Cashu token |
402 | Payment Required - Insufficient funds |
404 | Not Found - Model not found |
429 | Too Many Requests - Rate limit exceeded |
500 | Server Error - Something went wrong |