Skip to main content

Quickstart

Send the same chat completion request using the stack you prefer. All examples target the OpenAI-compatible gateway at https://router.hpp.io.

Prerequisites

  • An HPP Router API key from HPP Hub
  • Base URL: https://router.hpp.io

Store your key in an environment variable:

export HPPROUTER_API_KEY="your-api-key"

Send a chat completion

Install the package you need before running an SDK example:

  • TypeScript SDK: npm install @hpprouter/sdk
  • OpenAI SDK: npm install openai
  • Python: pip install openai
import { HppRouter } from '@hpprouter/sdk';

const client = new HppRouter({
apiKey: process.env.HPPROUTER_API_KEY!,
baseURL: 'https://router.hpp.io',
});

const completion = await client.chat.send({
model: 'hpprouter/auto',
messages: [{ role: 'user', content: 'Hello!' }],
});

console.log(completion.data.choices);
console.log(completion.meta.resolvedModel);

See the Client SDK and OpenAI SDK (drop-in) guides for more examples.

Response

A successful response includes choices and a usage block:

{
"id": "chatcmpl-...",
"object": "chat.completion",
"model": "openai/gpt-4o-mini",
"choices": [
{ "message": { "role": "assistant", "content": "Hi there!" } }
],
"usage": {
"prompt_tokens": 8,
"completion_tokens": 12,
"total_tokens": 20
}
}

When you use hpprouter/auto, the model used for billing is returned in the X-HPP-Router-Resolved-Model response header. See Smart Routing.

Next steps