API Reference
Peerwave offers a chat endpoint that is mostly compliant with OpenAI's chat API, making it a drop-in replacement for most applications. Access LLMs with both streaming and non-streaming responses.
Basic Chat Request
Send a message to an LLM model and get a response. This API is synchronous and returns a single response.
Try Basic Chat Request
Response Format
Parameters
model (required)
Which model to generate a completion with. Available models can be found with the /api/models endpoint. Several meta-models are available which describe classes of models without specifying them by name.
messages (required)
An array of message objects. Message objects have the following fields:
role- Can besystem,user,assistant, ortoolcontent- The content of the messageimages- A list of base64 encoded images for multimodal modelstool_calls- A list of tools the model wants to use (usually generated by the model)
format (optional)
Currently only `json` is supported to request JSON-formatted responses.
Streaming Chat Request
LLM responses can take a while to complete, especially for large generated responses (e.g. "generate 100 haikus"). To start seeing responses immediately, use the /api/chat/stream endpoint. This endpoint takes the same parameters as /api/chat.
JavaScript Streaming Example
The response is in newline delimited JSON. All responses follow the same format except for the last message which indicates completion and tells you how many credits the interaction took:
Streaming Response Format
Get Available Models
The available models on the network change as providers connect and disconnect. To get the currently available models, use the `/api/models` endpoint.
Try Get Available Models
Response Format
Meta Models
Meta models are models that describe classes of models without specifying them by name. For example, the cheapest meta-model will always return the cheapest available model.
This is useful for when you want to do something with the network but not worry about what is actively available or has sufficient capacity. When using meta models, the response will indicate which model was actually used to complete a request.
The following meta models are available:
cheapest- Always returns the cheapest available modelfastest- Pick the provider that can serve tokens most quickly