curl --request POST \
--url https://api.usehasp.com/v1/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"messages": [
{
"content": "<string>"
}
],
"max_tokens": 16000,
"tool_choice": "<string>",
"stream": true,
"temperature": 0.5,
"top_p": 0.5,
"top_k": 2,
"provider_extensions": [
"<string>"
],
"stop_sequences": [
"<string>"
],
"metadata": {
"user_id": "<string>"
},
"on_behalf_of": {
"id": "<string>",
"display": "<string>"
},
"system": [
{
"type": "text",
"text": "<string>",
"cache_control": {
"type": "ephemeral"
}
}
],
"tools": [
{
"name": "<string>",
"description": "<string>",
"input_schema": {
"type": "<string>"
},
"cache_control": {
"type": "ephemeral"
}
}
]
}
'import requests
url = "https://api.usehasp.com/v1/messages"
payload = {
"model": "<string>",
"messages": [{ "content": "<string>" }],
"max_tokens": 16000,
"tool_choice": "<string>",
"stream": True,
"temperature": 0.5,
"top_p": 0.5,
"top_k": 2,
"provider_extensions": ["<string>"],
"stop_sequences": ["<string>"],
"metadata": { "user_id": "<string>" },
"on_behalf_of": {
"id": "<string>",
"display": "<string>"
},
"system": [
{
"type": "text",
"text": "<string>",
"cache_control": { "type": "ephemeral" }
}
],
"tools": [
{
"name": "<string>",
"description": "<string>",
"input_schema": { "type": "<string>" },
"cache_control": { "type": "ephemeral" }
}
]
}
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>'}],
max_tokens: 16000,
tool_choice: '<string>',
stream: true,
temperature: 0.5,
top_p: 0.5,
top_k: 2,
provider_extensions: ['<string>'],
stop_sequences: ['<string>'],
metadata: {user_id: '<string>'},
on_behalf_of: {id: '<string>', display: '<string>'},
system: [{type: 'text', text: '<string>', cache_control: {type: 'ephemeral'}}],
tools: [
{
name: '<string>',
description: '<string>',
input_schema: {type: '<string>'},
cache_control: {type: 'ephemeral'}
}
]
})
};
fetch('https://api.usehasp.com/v1/messages', 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/messages",
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>'
]
],
'max_tokens' => 16000,
'tool_choice' => '<string>',
'stream' => true,
'temperature' => 0.5,
'top_p' => 0.5,
'top_k' => 2,
'provider_extensions' => [
'<string>'
],
'stop_sequences' => [
'<string>'
],
'metadata' => [
'user_id' => '<string>'
],
'on_behalf_of' => [
'id' => '<string>',
'display' => '<string>'
],
'system' => [
[
'type' => 'text',
'text' => '<string>',
'cache_control' => [
'type' => 'ephemeral'
]
]
],
'tools' => [
[
'name' => '<string>',
'description' => '<string>',
'input_schema' => [
'type' => '<string>'
],
'cache_control' => [
'type' => 'ephemeral'
]
]
]
]),
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/messages"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"messages\": [\n {\n \"content\": \"<string>\"\n }\n ],\n \"max_tokens\": 16000,\n \"tool_choice\": \"<string>\",\n \"stream\": true,\n \"temperature\": 0.5,\n \"top_p\": 0.5,\n \"top_k\": 2,\n \"provider_extensions\": [\n \"<string>\"\n ],\n \"stop_sequences\": [\n \"<string>\"\n ],\n \"metadata\": {\n \"user_id\": \"<string>\"\n },\n \"on_behalf_of\": {\n \"id\": \"<string>\",\n \"display\": \"<string>\"\n },\n \"system\": [\n {\n \"type\": \"text\",\n \"text\": \"<string>\",\n \"cache_control\": {\n \"type\": \"ephemeral\"\n }\n }\n ],\n \"tools\": [\n {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"input_schema\": {\n \"type\": \"<string>\"\n },\n \"cache_control\": {\n \"type\": \"ephemeral\"\n }\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/messages")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"messages\": [\n {\n \"content\": \"<string>\"\n }\n ],\n \"max_tokens\": 16000,\n \"tool_choice\": \"<string>\",\n \"stream\": true,\n \"temperature\": 0.5,\n \"top_p\": 0.5,\n \"top_k\": 2,\n \"provider_extensions\": [\n \"<string>\"\n ],\n \"stop_sequences\": [\n \"<string>\"\n ],\n \"metadata\": {\n \"user_id\": \"<string>\"\n },\n \"on_behalf_of\": {\n \"id\": \"<string>\",\n \"display\": \"<string>\"\n },\n \"system\": [\n {\n \"type\": \"text\",\n \"text\": \"<string>\",\n \"cache_control\": {\n \"type\": \"ephemeral\"\n }\n }\n ],\n \"tools\": [\n {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"input_schema\": {\n \"type\": \"<string>\"\n },\n \"cache_control\": {\n \"type\": \"ephemeral\"\n }\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.usehasp.com/v1/messages")
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 }\n ],\n \"max_tokens\": 16000,\n \"tool_choice\": \"<string>\",\n \"stream\": true,\n \"temperature\": 0.5,\n \"top_p\": 0.5,\n \"top_k\": 2,\n \"provider_extensions\": [\n \"<string>\"\n ],\n \"stop_sequences\": [\n \"<string>\"\n ],\n \"metadata\": {\n \"user_id\": \"<string>\"\n },\n \"on_behalf_of\": {\n \"id\": \"<string>\",\n \"display\": \"<string>\"\n },\n \"system\": [\n {\n \"type\": \"text\",\n \"text\": \"<string>\",\n \"cache_control\": {\n \"type\": \"ephemeral\"\n }\n }\n ],\n \"tools\": [\n {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"input_schema\": {\n \"type\": \"<string>\"\n },\n \"cache_control\": {\n \"type\": \"ephemeral\"\n }\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"type": "<string>",
"role": "<string>",
"content": [
{
"type": "<string>",
"text": "<string>"
}
],
"model": "<unknown>",
"stop_reason": "<string>",
"stop_sequence": null,
"usage": {
"input_tokens": 123,
"output_tokens": 123,
"cache_creation_input_tokens": 123,
"cache_read_input_tokens": 123
},
"meta": {
"request_id": "<string>"
}
}{
"type": "<string>",
"error": {
"type": "<string>",
"message": "<string>",
"hasp_code": "<string>",
"hasp_details": {
"parameter": "<string>"
},
"param": "<string>"
}
}"<string>"{
"message": "<string>"
}{
"message": "<string>",
"errors": {}
}"<string>"Handle an Anthropic Messages-compatible request, streaming or returning the assembled response
curl --request POST \
--url https://api.usehasp.com/v1/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"messages": [
{
"content": "<string>"
}
],
"max_tokens": 16000,
"tool_choice": "<string>",
"stream": true,
"temperature": 0.5,
"top_p": 0.5,
"top_k": 2,
"provider_extensions": [
"<string>"
],
"stop_sequences": [
"<string>"
],
"metadata": {
"user_id": "<string>"
},
"on_behalf_of": {
"id": "<string>",
"display": "<string>"
},
"system": [
{
"type": "text",
"text": "<string>",
"cache_control": {
"type": "ephemeral"
}
}
],
"tools": [
{
"name": "<string>",
"description": "<string>",
"input_schema": {
"type": "<string>"
},
"cache_control": {
"type": "ephemeral"
}
}
]
}
'import requests
url = "https://api.usehasp.com/v1/messages"
payload = {
"model": "<string>",
"messages": [{ "content": "<string>" }],
"max_tokens": 16000,
"tool_choice": "<string>",
"stream": True,
"temperature": 0.5,
"top_p": 0.5,
"top_k": 2,
"provider_extensions": ["<string>"],
"stop_sequences": ["<string>"],
"metadata": { "user_id": "<string>" },
"on_behalf_of": {
"id": "<string>",
"display": "<string>"
},
"system": [
{
"type": "text",
"text": "<string>",
"cache_control": { "type": "ephemeral" }
}
],
"tools": [
{
"name": "<string>",
"description": "<string>",
"input_schema": { "type": "<string>" },
"cache_control": { "type": "ephemeral" }
}
]
}
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>'}],
max_tokens: 16000,
tool_choice: '<string>',
stream: true,
temperature: 0.5,
top_p: 0.5,
top_k: 2,
provider_extensions: ['<string>'],
stop_sequences: ['<string>'],
metadata: {user_id: '<string>'},
on_behalf_of: {id: '<string>', display: '<string>'},
system: [{type: 'text', text: '<string>', cache_control: {type: 'ephemeral'}}],
tools: [
{
name: '<string>',
description: '<string>',
input_schema: {type: '<string>'},
cache_control: {type: 'ephemeral'}
}
]
})
};
fetch('https://api.usehasp.com/v1/messages', 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/messages",
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>'
]
],
'max_tokens' => 16000,
'tool_choice' => '<string>',
'stream' => true,
'temperature' => 0.5,
'top_p' => 0.5,
'top_k' => 2,
'provider_extensions' => [
'<string>'
],
'stop_sequences' => [
'<string>'
],
'metadata' => [
'user_id' => '<string>'
],
'on_behalf_of' => [
'id' => '<string>',
'display' => '<string>'
],
'system' => [
[
'type' => 'text',
'text' => '<string>',
'cache_control' => [
'type' => 'ephemeral'
]
]
],
'tools' => [
[
'name' => '<string>',
'description' => '<string>',
'input_schema' => [
'type' => '<string>'
],
'cache_control' => [
'type' => 'ephemeral'
]
]
]
]),
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/messages"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"messages\": [\n {\n \"content\": \"<string>\"\n }\n ],\n \"max_tokens\": 16000,\n \"tool_choice\": \"<string>\",\n \"stream\": true,\n \"temperature\": 0.5,\n \"top_p\": 0.5,\n \"top_k\": 2,\n \"provider_extensions\": [\n \"<string>\"\n ],\n \"stop_sequences\": [\n \"<string>\"\n ],\n \"metadata\": {\n \"user_id\": \"<string>\"\n },\n \"on_behalf_of\": {\n \"id\": \"<string>\",\n \"display\": \"<string>\"\n },\n \"system\": [\n {\n \"type\": \"text\",\n \"text\": \"<string>\",\n \"cache_control\": {\n \"type\": \"ephemeral\"\n }\n }\n ],\n \"tools\": [\n {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"input_schema\": {\n \"type\": \"<string>\"\n },\n \"cache_control\": {\n \"type\": \"ephemeral\"\n }\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/messages")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"messages\": [\n {\n \"content\": \"<string>\"\n }\n ],\n \"max_tokens\": 16000,\n \"tool_choice\": \"<string>\",\n \"stream\": true,\n \"temperature\": 0.5,\n \"top_p\": 0.5,\n \"top_k\": 2,\n \"provider_extensions\": [\n \"<string>\"\n ],\n \"stop_sequences\": [\n \"<string>\"\n ],\n \"metadata\": {\n \"user_id\": \"<string>\"\n },\n \"on_behalf_of\": {\n \"id\": \"<string>\",\n \"display\": \"<string>\"\n },\n \"system\": [\n {\n \"type\": \"text\",\n \"text\": \"<string>\",\n \"cache_control\": {\n \"type\": \"ephemeral\"\n }\n }\n ],\n \"tools\": [\n {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"input_schema\": {\n \"type\": \"<string>\"\n },\n \"cache_control\": {\n \"type\": \"ephemeral\"\n }\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.usehasp.com/v1/messages")
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 }\n ],\n \"max_tokens\": 16000,\n \"tool_choice\": \"<string>\",\n \"stream\": true,\n \"temperature\": 0.5,\n \"top_p\": 0.5,\n \"top_k\": 2,\n \"provider_extensions\": [\n \"<string>\"\n ],\n \"stop_sequences\": [\n \"<string>\"\n ],\n \"metadata\": {\n \"user_id\": \"<string>\"\n },\n \"on_behalf_of\": {\n \"id\": \"<string>\",\n \"display\": \"<string>\"\n },\n \"system\": [\n {\n \"type\": \"text\",\n \"text\": \"<string>\",\n \"cache_control\": {\n \"type\": \"ephemeral\"\n }\n }\n ],\n \"tools\": [\n {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"input_schema\": {\n \"type\": \"<string>\"\n },\n \"cache_control\": {\n \"type\": \"ephemeral\"\n }\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"type": "<string>",
"role": "<string>",
"content": [
{
"type": "<string>",
"text": "<string>"
}
],
"model": "<unknown>",
"stop_reason": "<string>",
"stop_sequence": null,
"usage": {
"input_tokens": 123,
"output_tokens": 123,
"cache_creation_input_tokens": 123,
"cache_read_input_tokens": 123
},
"meta": {
"request_id": "<string>"
}
}{
"type": "<string>",
"error": {
"type": "<string>",
"message": "<string>",
"hasp_code": "<string>",
"hasp_details": {
"parameter": "<string>"
},
"param": "<string>"
}
}"<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/messages (Anthropic-compat) per PRD §05-public-api.
Accepts Anthropic's exact wire format so existing @anthropic-ai/sdk
integrations (including coding agents such as Claude Code, per ADR-YGE00M)
need only change the baseURL: structured content blocks (text / tool_use /
tool_result / image), tool definitions, and cache_control markers on
system blocks, content blocks, and tool definitions.
HASP-native flags (e.g. 'store') are rejected with 400 UNSUPPORTED_PARAMETER per PRD §05: "rejecting rather than silently accepting keeps the contract honest."
1001Show child attributes
Show child attributes
1 <= x <= 32000Shape-validated here; normalized by AnthropicMessagesRequestBuilder::buildToolChoice() and enforced by AiGatewayService::assertParametersSupported() (HASP-509).
0 <= x <= 10 <= x <= 1x >= 1Escape hatch for Anthropic-specific wire keys the canonical fields above don't (yet) model — see ADR-ZP99PX. Merged into the raw wire payload by DirectProviderDriver; rejected with UNSUPPORTED_PARAMETER on drivers that can't honor it.
Show child attributes
Show child attributes
Asserted end-user identity — a HASP extension on the Anthropic
wire shape (Anthropic SDK users send it via extra_body).
Records which user of your application took this action on the
audit chain, as an assertion made by your integration — HASP
does not verify it, it is never forwarded to the model
provider, and it is never shown to the model. Distinct from
metadata.user_id, which is provider metadata. Supported for
API-key credentials only.
Show child attributes
Show child attributes
System is either a plain string or an array of blocks carrying per-block cache_control (Anthropic's system-prompt caching shape).
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Response
"message""assistant"- Option 1
- Option 2
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes