curl --request POST \
--url https://api.withhopper.com/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"messages": [
{}
],
"stream": false,
"temperature": 123,
"max_tokens": 123,
"tools": [
{}
],
"stream_options": {
"include_usage": true
}
}
'import requests
url = "https://api.withhopper.com/v1/chat/completions"
payload = {
"model": "<string>",
"messages": [{}],
"stream": False,
"temperature": 123,
"max_tokens": 123,
"tools": [{}],
"stream_options": { "include_usage": True }
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: '<string>',
messages: [{}],
stream: false,
temperature: 123,
max_tokens: 123,
tools: [{}],
stream_options: {include_usage: true}
})
};
fetch('https://api.withhopper.com/v1/chat/completions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.withhopper.com/v1/chat/completions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => '<string>',
'messages' => [
[
]
],
'stream' => false,
'temperature' => 123,
'max_tokens' => 123,
'tools' => [
[
]
],
'stream_options' => [
'include_usage' => true
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.withhopper.com/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"messages\": [\n {}\n ],\n \"stream\": false,\n \"temperature\": 123,\n \"max_tokens\": 123,\n \"tools\": [\n {}\n ],\n \"stream_options\": {\n \"include_usage\": true\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.withhopper.com/v1/chat/completions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"messages\": [\n {}\n ],\n \"stream\": false,\n \"temperature\": 123,\n \"max_tokens\": 123,\n \"tools\": [\n {}\n ],\n \"stream_options\": {\n \"include_usage\": true\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.withhopper.com/v1/chat/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"<string>\",\n \"messages\": [\n {}\n ],\n \"stream\": false,\n \"temperature\": 123,\n \"max_tokens\": 123,\n \"tools\": [\n {}\n ],\n \"stream_options\": {\n \"include_usage\": true\n }\n}"
response = http.request(request)
puts response.read_body{}{
"error": {
"message": "Incorrect API key provided. Check your key at https://withhopper.com/dashboard.",
"type": "invalid_request_error",
"code": "invalid_api_key",
"param": null
}
}{
"error": {
"message": "You have run out of credits. Contact us to add more.",
"type": "insufficient_quota",
"code": "insufficient_quota",
"param": null
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"message": "Rate limit reached: 600 requests per minute per key. Retry after 21s.",
"type": "rate_limit_error",
"code": "rate_limit_exceeded",
"param": null
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"message": "Key verification is temporarily unavailable. Retry shortly.",
"type": "api_error",
"code": "verify_unavailable",
"param": null
}
}Create chat completion
OpenAI-compatible chat completions. The body is forwarded to the inference engine unchanged, so any OpenAI chat completions parameter is accepted; the engine validates it. Request body cap: 10 MB.
curl --request POST \
--url https://api.withhopper.com/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"messages": [
{}
],
"stream": false,
"temperature": 123,
"max_tokens": 123,
"tools": [
{}
],
"stream_options": {
"include_usage": true
}
}
'import requests
url = "https://api.withhopper.com/v1/chat/completions"
payload = {
"model": "<string>",
"messages": [{}],
"stream": False,
"temperature": 123,
"max_tokens": 123,
"tools": [{}],
"stream_options": { "include_usage": True }
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: '<string>',
messages: [{}],
stream: false,
temperature: 123,
max_tokens: 123,
tools: [{}],
stream_options: {include_usage: true}
})
};
fetch('https://api.withhopper.com/v1/chat/completions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.withhopper.com/v1/chat/completions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => '<string>',
'messages' => [
[
]
],
'stream' => false,
'temperature' => 123,
'max_tokens' => 123,
'tools' => [
[
]
],
'stream_options' => [
'include_usage' => true
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.withhopper.com/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"messages\": [\n {}\n ],\n \"stream\": false,\n \"temperature\": 123,\n \"max_tokens\": 123,\n \"tools\": [\n {}\n ],\n \"stream_options\": {\n \"include_usage\": true\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.withhopper.com/v1/chat/completions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"messages\": [\n {}\n ],\n \"stream\": false,\n \"temperature\": 123,\n \"max_tokens\": 123,\n \"tools\": [\n {}\n ],\n \"stream_options\": {\n \"include_usage\": true\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.withhopper.com/v1/chat/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"<string>\",\n \"messages\": [\n {}\n ],\n \"stream\": false,\n \"temperature\": 123,\n \"max_tokens\": 123,\n \"tools\": [\n {}\n ],\n \"stream_options\": {\n \"include_usage\": true\n }\n}"
response = http.request(request)
puts response.read_body{}{
"error": {
"message": "Incorrect API key provided. Check your key at https://withhopper.com/dashboard.",
"type": "invalid_request_error",
"code": "invalid_api_key",
"param": null
}
}{
"error": {
"message": "You have run out of credits. Contact us to add more.",
"type": "insufficient_quota",
"code": "insufficient_quota",
"param": null
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"message": "Rate limit reached: 600 requests per minute per key. Retry after 21s.",
"type": "rate_limit_error",
"code": "rate_limit_exceeded",
"param": null
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"message": "Key verification is temporarily unavailable. Retry shortly.",
"type": "api_error",
"code": "verify_unavailable",
"param": null
}
}Authorizations
API key in the Authorization header: Bearer sk_hopper_... Keys are minted in the dashboard at withhopper.com/console/keys and shown once at creation. WebSocket connections also accept ?api_key=.
Body
Passed through to the inference engine. Fields below are the common subset; any other OpenAI chat completions parameter is also accepted.
Model id, e.g. gemma-4-31b.
OpenAI chat messages.
Stream tokens as SSE chunks.
Sampling temperature; passed through.
Maximum output tokens; passed through.
OpenAI tool definitions; passed through.
Set include_usage true to receive a final usage chunk. The gateway meters usage either way.
Show child attributes
Show child attributes
Response
Non-streaming: an OpenAI chat completion object with both spend headers. Streaming: text/event-stream of OpenAI chunks, with only x-hopper-credits-remaining-usd (the pre-request balance; cost is unknown until the stream ends).
OpenAI chat completion object, forwarded from the inference engine.