### GET /models Source: https://larprouter.com/docs Retrieves a list of models available to the provided API key. ```APIDOC ## GET /models ### Description Retrieves a list of models available to the provided API key. ### Method GET ### Endpoint /models ``` -------------------------------- ### Interact with Posty AI Source: https://larprouter.com/docs Examples for sending requests to the Posty AI chat endpoint using curl or JavaScript. ```curl curl -X POST https://larprouter.com/api/v1/chat -H "Authorization: Bearer lrsk-your-posty-key" -H "Content-Type: application/json" -d '{"message": "Hello Posty!", "model": "posty-2.0-retro"}' ``` ```javascript const response = await fetch('https://larprouter.com/api/v1/chat', { method: 'POST', headers: { 'Authorization': 'Bearer lrsk-your-posty-key', 'Content-Type': 'application/json', }, body: JSON.stringify({ message: 'Hello Posty!', model: 'posty-2.0-retro', }), }); const data = await response.json(); console.log(data.model); console.log(data.response); ``` -------------------------------- ### Perform a streaming request with Python Source: https://larprouter.com/docs Configure the OpenAI Python client to point to the LARPROUTER base URL for streaming completions. ```python from openai import OpenAI client = OpenAI( api_key="lrsk-your-key", base_url="https://larprouter.com/api/v1", ) response = client.chat.completions.create( model="MODEL_ID_FROM_CLIENT_MODELS_LIST", messages=[{"role": "user", "content": "Hello!"}], stream=True, ) for chunk in response: print(chunk.choices[0].delta.content, end="") ``` -------------------------------- ### Perform a streaming request with cURL Source: https://larprouter.com/docs Use the standard cURL command to interact with the gateway by setting the Authorization header and base URL. ```bash curl https://larprouter.com/api/v1/chat/completions \ -H "Authorization: Bearer lrsk-your-key" \ -H "Content-Type: application/json" \ -d '{ "model": "MODEL_ID_FROM_GET_API_V1_MODELS", "messages": [{"role": "user", "content": "Hello!"}], "stream": true }' ``` -------------------------------- ### Perform a streaming request with Node.js Source: https://larprouter.com/docs Use the OpenAI Node.js client with the LARPROUTER base URL to handle streaming responses. ```javascript import OpenAI from "openai"; const client = new OpenAI({ apiKey: "lrsk-your-key", baseURL: "https://larprouter.com/api/v1", }); const stream = await client.chat.completions.create({ model: "MODEL_ID_FROM_CLIENT_MODELS_LIST", messages: [{ role: "user", content: "Hello!" }], stream: true, }); for await (const chunk of stream) { process.stdout.write(chunk.choices[0]?.delta?.content ?? ""); } ``` -------------------------------- ### Configure Authentication Headers Source: https://larprouter.com/docs Use these headers to authenticate requests to the LarpRouter gateway. ```http Authorization: Bearer lrsk-your-key # Anthropic-style header also works x-api-key: lrsk-your-key ``` -------------------------------- ### POST /chat/completions Source: https://larprouter.com/docs Provides an OpenAI-compatible chat completion endpoint. ```APIDOC ## POST /chat/completions ### Description Provides an OpenAI-compatible chat completion endpoint. ### Method POST ### Endpoint /chat/completions ``` -------------------------------- ### POST /chat/completions Source: https://larprouter.com/docs Creates a chat completion request to the specified model. This endpoint is compatible with the standard OpenAI chat completions API. ```APIDOC ## POST /chat/completions ### Description Sends a chat completion request to the gateway, which routes it to the specified model. Supports streaming responses via Server-Sent Events (SSE). ### Method POST ### Endpoint https://larprouter.com/api/v1/chat/completions ### Request Body - **model** (string) - Required - The ID of the model to use. - **messages** (array) - Required - A list of message objects containing role and content. - **stream** (boolean) - Optional - Whether to stream the response. ``` -------------------------------- ### POST /chat Source: https://larprouter.com/docs Keyless Posty AI chat endpoint for native message requests. ```APIDOC ## POST /chat ### Description Keyless Posty AI chat endpoint for native message requests. ### Method POST ### Endpoint /chat ### Request Body - **message** (string) - Required - The message content for the AI. - **model** (string) - Optional - The model ID to use (defaults to posty-1.8-mini). ``` -------------------------------- ### POST /messages Source: https://larprouter.com/docs Provides an Anthropic-compatible messages endpoint. ```APIDOC ## POST /messages ### Description Provides an Anthropic-compatible messages endpoint. ### Method POST ### Endpoint /messages ``` -------------------------------- ### Streaming Gateway Endpoints Source: https://larprouter.com/docs The gateway supports streaming responses via server-sent events for OpenAI Chat Completions and Anthropic Messages formats. ```APIDOC ## Streaming ### Description OpenAI and Anthropic gateway endpoints support streaming over server-sent events. Clients must pass `stream: true` to receive responses as they arrive. ### Usage - Streams remain open for up to 600 seconds. - Clients may reconnect if the stream is interrupted. - Supports OpenAI Chat Completions and Anthropic Messages formats. ``` -------------------------------- ### Error Handling Source: https://larprouter.com/docs Reference for standard HTTP status codes and machine-readable error types returned by the API. ```APIDOC ## Error Codes | Status | Type | Meaning | Resolution | |---|---|---|---| | 401 | `authentication_error` | Invalid or missing API key | Check the Authorization header | | 402 | `insufficient_credit` | Account has no credits | Add credit in billing | | 429 | `rate_limit_error` | Key balance exhausted or too many requests | Back off and retry | | 503 | `service_unavailable` | Model pool temporarily unavailable | Retry with backoff | ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.