curl --request POST \
--url https://api.usehasp.com/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"messages": [
{
"content": "<string>",
"name": "<string>",
"tool_call_id": "<string>",
"tool_calls": [
{
"id": "<string>",
"type": "function"
}
]
}
],
"tool_choice": "<string>",
"max_tokens": 16000,
"stream": true,
"temperature": 1,
"top_p": 0.5,
"n": 123,
"frequency_penalty": 0,
"presence_penalty": 0,
"user": "<string>",
"provider_extensions": [
"<string>"
],
"stop": [
"<string>"
],
"tools": [
{
"type": "function"
}
]
}
'import requests
url = "https://api.usehasp.com/v1/chat/completions"
payload = {
"model": "<string>",
"messages": [
{
"content": "<string>",
"name": "<string>",
"tool_call_id": "<string>",
"tool_calls": [
{
"id": "<string>",
"type": "function"
}
]
}
],
"tool_choice": "<string>",
"max_tokens": 16000,
"stream": True,
"temperature": 1,
"top_p": 0.5,
"n": 123,
"frequency_penalty": 0,
"presence_penalty": 0,
"user": "<string>",
"provider_extensions": ["<string>"],
"stop": ["<string>"],
"tools": [{ "type": "function" }]
}
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: [
{
content: '<string>',
name: '<string>',
tool_call_id: '<string>',
tool_calls: [{id: '<string>', type: 'function'}]
}
],
tool_choice: '<string>',
max_tokens: 16000,
stream: true,
temperature: 1,
top_p: 0.5,
n: 123,
frequency_penalty: 0,
presence_penalty: 0,
user: '<string>',
provider_extensions: ['<string>'],
stop: ['<string>'],
tools: [{type: 'function'}]
})
};
fetch('https://api.usehasp.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.usehasp.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' => [
[
'content' => '<string>',
'name' => '<string>',
'tool_call_id' => '<string>',
'tool_calls' => [
[
'id' => '<string>',
'type' => 'function'
]
]
]
],
'tool_choice' => '<string>',
'max_tokens' => 16000,
'stream' => true,
'temperature' => 1,
'top_p' => 0.5,
'n' => 123,
'frequency_penalty' => 0,
'presence_penalty' => 0,
'user' => '<string>',
'provider_extensions' => [
'<string>'
],
'stop' => [
'<string>'
],
'tools' => [
[
'type' => 'function'
]
]
]),
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.usehasp.com/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"messages\": [\n {\n \"content\": \"<string>\",\n \"name\": \"<string>\",\n \"tool_call_id\": \"<string>\",\n \"tool_calls\": [\n {\n \"id\": \"<string>\",\n \"type\": \"function\"\n }\n ]\n }\n ],\n \"tool_choice\": \"<string>\",\n \"max_tokens\": 16000,\n \"stream\": true,\n \"temperature\": 1,\n \"top_p\": 0.5,\n \"n\": 123,\n \"frequency_penalty\": 0,\n \"presence_penalty\": 0,\n \"user\": \"<string>\",\n \"provider_extensions\": [\n \"<string>\"\n ],\n \"stop\": [\n \"<string>\"\n ],\n \"tools\": [\n {\n \"type\": \"function\"\n }\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.usehasp.com/v1/chat/completions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"messages\": [\n {\n \"content\": \"<string>\",\n \"name\": \"<string>\",\n \"tool_call_id\": \"<string>\",\n \"tool_calls\": [\n {\n \"id\": \"<string>\",\n \"type\": \"function\"\n }\n ]\n }\n ],\n \"tool_choice\": \"<string>\",\n \"max_tokens\": 16000,\n \"stream\": true,\n \"temperature\": 1,\n \"top_p\": 0.5,\n \"n\": 123,\n \"frequency_penalty\": 0,\n \"presence_penalty\": 0,\n \"user\": \"<string>\",\n \"provider_extensions\": [\n \"<string>\"\n ],\n \"stop\": [\n \"<string>\"\n ],\n \"tools\": [\n {\n \"type\": \"function\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.usehasp.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 \"content\": \"<string>\",\n \"name\": \"<string>\",\n \"tool_call_id\": \"<string>\",\n \"tool_calls\": [\n {\n \"id\": \"<string>\",\n \"type\": \"function\"\n }\n ]\n }\n ],\n \"tool_choice\": \"<string>\",\n \"max_tokens\": 16000,\n \"stream\": true,\n \"temperature\": 1,\n \"top_p\": 0.5,\n \"n\": 123,\n \"frequency_penalty\": 0,\n \"presence_penalty\": 0,\n \"user\": \"<string>\",\n \"provider_extensions\": [\n \"<string>\"\n ],\n \"stop\": [\n \"<string>\"\n ],\n \"tools\": [\n {\n \"type\": \"function\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"object": "<string>",
"created": 123,
"model": "<unknown>",
"choices": [
{
"index": 123,
"message": {
"role": "<string>",
"content": "<string>",
"tool_calls": [
"<unknown>"
]
}
}
],
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"total_tokens": 123
}
}"<string>"{
"message": "<string>"
}{
"message": "<string>",
"errors": {}
}"<string>"Handle an OpenAI Chat Completions-compatible request, streaming or returning the assembled response
curl --request POST \
--url https://api.usehasp.com/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"messages": [
{
"content": "<string>",
"name": "<string>",
"tool_call_id": "<string>",
"tool_calls": [
{
"id": "<string>",
"type": "function"
}
]
}
],
"tool_choice": "<string>",
"max_tokens": 16000,
"stream": true,
"temperature": 1,
"top_p": 0.5,
"n": 123,
"frequency_penalty": 0,
"presence_penalty": 0,
"user": "<string>",
"provider_extensions": [
"<string>"
],
"stop": [
"<string>"
],
"tools": [
{
"type": "function"
}
]
}
'import requests
url = "https://api.usehasp.com/v1/chat/completions"
payload = {
"model": "<string>",
"messages": [
{
"content": "<string>",
"name": "<string>",
"tool_call_id": "<string>",
"tool_calls": [
{
"id": "<string>",
"type": "function"
}
]
}
],
"tool_choice": "<string>",
"max_tokens": 16000,
"stream": True,
"temperature": 1,
"top_p": 0.5,
"n": 123,
"frequency_penalty": 0,
"presence_penalty": 0,
"user": "<string>",
"provider_extensions": ["<string>"],
"stop": ["<string>"],
"tools": [{ "type": "function" }]
}
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: [
{
content: '<string>',
name: '<string>',
tool_call_id: '<string>',
tool_calls: [{id: '<string>', type: 'function'}]
}
],
tool_choice: '<string>',
max_tokens: 16000,
stream: true,
temperature: 1,
top_p: 0.5,
n: 123,
frequency_penalty: 0,
presence_penalty: 0,
user: '<string>',
provider_extensions: ['<string>'],
stop: ['<string>'],
tools: [{type: 'function'}]
})
};
fetch('https://api.usehasp.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.usehasp.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' => [
[
'content' => '<string>',
'name' => '<string>',
'tool_call_id' => '<string>',
'tool_calls' => [
[
'id' => '<string>',
'type' => 'function'
]
]
]
],
'tool_choice' => '<string>',
'max_tokens' => 16000,
'stream' => true,
'temperature' => 1,
'top_p' => 0.5,
'n' => 123,
'frequency_penalty' => 0,
'presence_penalty' => 0,
'user' => '<string>',
'provider_extensions' => [
'<string>'
],
'stop' => [
'<string>'
],
'tools' => [
[
'type' => 'function'
]
]
]),
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.usehasp.com/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"messages\": [\n {\n \"content\": \"<string>\",\n \"name\": \"<string>\",\n \"tool_call_id\": \"<string>\",\n \"tool_calls\": [\n {\n \"id\": \"<string>\",\n \"type\": \"function\"\n }\n ]\n }\n ],\n \"tool_choice\": \"<string>\",\n \"max_tokens\": 16000,\n \"stream\": true,\n \"temperature\": 1,\n \"top_p\": 0.5,\n \"n\": 123,\n \"frequency_penalty\": 0,\n \"presence_penalty\": 0,\n \"user\": \"<string>\",\n \"provider_extensions\": [\n \"<string>\"\n ],\n \"stop\": [\n \"<string>\"\n ],\n \"tools\": [\n {\n \"type\": \"function\"\n }\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.usehasp.com/v1/chat/completions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"messages\": [\n {\n \"content\": \"<string>\",\n \"name\": \"<string>\",\n \"tool_call_id\": \"<string>\",\n \"tool_calls\": [\n {\n \"id\": \"<string>\",\n \"type\": \"function\"\n }\n ]\n }\n ],\n \"tool_choice\": \"<string>\",\n \"max_tokens\": 16000,\n \"stream\": true,\n \"temperature\": 1,\n \"top_p\": 0.5,\n \"n\": 123,\n \"frequency_penalty\": 0,\n \"presence_penalty\": 0,\n \"user\": \"<string>\",\n \"provider_extensions\": [\n \"<string>\"\n ],\n \"stop\": [\n \"<string>\"\n ],\n \"tools\": [\n {\n \"type\": \"function\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.usehasp.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 \"content\": \"<string>\",\n \"name\": \"<string>\",\n \"tool_call_id\": \"<string>\",\n \"tool_calls\": [\n {\n \"id\": \"<string>\",\n \"type\": \"function\"\n }\n ]\n }\n ],\n \"tool_choice\": \"<string>\",\n \"max_tokens\": 16000,\n \"stream\": true,\n \"temperature\": 1,\n \"top_p\": 0.5,\n \"n\": 123,\n \"frequency_penalty\": 0,\n \"presence_penalty\": 0,\n \"user\": \"<string>\",\n \"provider_extensions\": [\n \"<string>\"\n ],\n \"stop\": [\n \"<string>\"\n ],\n \"tools\": [\n {\n \"type\": \"function\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"object": "<string>",
"created": 123,
"model": "<unknown>",
"choices": [
{
"index": 123,
"message": {
"role": "<string>",
"content": "<string>",
"tool_calls": [
"<unknown>"
]
}
}
],
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"total_tokens": 123
}
}"<string>"{
"message": "<string>"
}{
"message": "<string>",
"errors": {}
}"<string>"Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
Validates POST /v1/chat/completions (OpenAI-compat) per ADR-YGE00M.
Accepts OpenAI's Chat Completions wire format: system/user/assistant/tool
role messages, function-tool definitions, and tool_calls/tool_call_id for
round-tripping tool results. top_p, tool_choice, and stop are wired
into InferenceRequest's canonical topP/toolChoice/stopSequences
fields (HASP-509); user is forwarded as metadata.user_id, a documented
graceful degrade on this surface (see DirectProviderDriver::supports()) —
OpenAI's real API accepts it but HASP's OpenAI driver does not forward it
upstream today. n, frequency_penalty, and presence_penalty are
outside the cross-provider parameter model this DTO carries (no Anthropic
analog) and remain validated for shape but otherwise ignored.
1001Show child attributes
Show child attributes
1 <= x <= 320000 <= x <= 20 <= x <= 1-2 <= x <= 2-2 <= x <= 2255Escape hatch for provider-specific wire keys the canonical fields above don't (yet) model — see ADR-ZP99PX. No OpenAI driver wiring exists today (see DirectProviderDriver::supports()), so setting this is rejected with UNSUPPORTED_PARAMETER rather than silently dropped.
Show child attributes
Show child attributes