curl --request POST \
--url https://api.usehasp.com/v1/ai/chat \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"message": "<string>",
"model": "<string>",
"conversation_id": "<string>",
"stream": true,
"store": true,
"system": "<string>",
"tool_choice": "<string>",
"top_p": 0.5,
"top_k": 2,
"provider_extensions": [
"<string>"
],
"stop_sequences": [
"<string>"
],
"metadata": {
"user_id": "<string>"
},
"subject": {
"type": "<string>",
"id": "<string>"
},
"on_behalf_of": {
"id": "<string>",
"display": "<string>"
},
"messages": [
{
"content": "<string>"
}
],
"tools": [
{
"name": "<string>",
"description": "<string>",
"input_schema": {
"type": "<string>"
}
}
]
}
'import requests
url = "https://api.usehasp.com/v1/ai/chat"
payload = {
"message": "<string>",
"model": "<string>",
"conversation_id": "<string>",
"stream": True,
"store": True,
"system": "<string>",
"tool_choice": "<string>",
"top_p": 0.5,
"top_k": 2,
"provider_extensions": ["<string>"],
"stop_sequences": ["<string>"],
"metadata": { "user_id": "<string>" },
"subject": {
"type": "<string>",
"id": "<string>"
},
"on_behalf_of": {
"id": "<string>",
"display": "<string>"
},
"messages": [{ "content": "<string>" }],
"tools": [
{
"name": "<string>",
"description": "<string>",
"input_schema": { "type": "<string>" }
}
]
}
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({
message: '<string>',
model: '<string>',
conversation_id: '<string>',
stream: true,
store: true,
system: '<string>',
tool_choice: '<string>',
top_p: 0.5,
top_k: 2,
provider_extensions: ['<string>'],
stop_sequences: ['<string>'],
metadata: {user_id: '<string>'},
subject: {type: '<string>', id: '<string>'},
on_behalf_of: {id: '<string>', display: '<string>'},
messages: [{content: '<string>'}],
tools: [{name: '<string>', description: '<string>', input_schema: {type: '<string>'}}]
})
};
fetch('https://api.usehasp.com/v1/ai/chat', 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/ai/chat",
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([
'message' => '<string>',
'model' => '<string>',
'conversation_id' => '<string>',
'stream' => true,
'store' => true,
'system' => '<string>',
'tool_choice' => '<string>',
'top_p' => 0.5,
'top_k' => 2,
'provider_extensions' => [
'<string>'
],
'stop_sequences' => [
'<string>'
],
'metadata' => [
'user_id' => '<string>'
],
'subject' => [
'type' => '<string>',
'id' => '<string>'
],
'on_behalf_of' => [
'id' => '<string>',
'display' => '<string>'
],
'messages' => [
[
'content' => '<string>'
]
],
'tools' => [
[
'name' => '<string>',
'description' => '<string>',
'input_schema' => [
'type' => '<string>'
]
]
]
]),
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/ai/chat"
payload := strings.NewReader("{\n \"message\": \"<string>\",\n \"model\": \"<string>\",\n \"conversation_id\": \"<string>\",\n \"stream\": true,\n \"store\": true,\n \"system\": \"<string>\",\n \"tool_choice\": \"<string>\",\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 \"subject\": {\n \"type\": \"<string>\",\n \"id\": \"<string>\"\n },\n \"on_behalf_of\": {\n \"id\": \"<string>\",\n \"display\": \"<string>\"\n },\n \"messages\": [\n {\n \"content\": \"<string>\"\n }\n ],\n \"tools\": [\n {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"input_schema\": {\n \"type\": \"<string>\"\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/ai/chat")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"message\": \"<string>\",\n \"model\": \"<string>\",\n \"conversation_id\": \"<string>\",\n \"stream\": true,\n \"store\": true,\n \"system\": \"<string>\",\n \"tool_choice\": \"<string>\",\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 \"subject\": {\n \"type\": \"<string>\",\n \"id\": \"<string>\"\n },\n \"on_behalf_of\": {\n \"id\": \"<string>\",\n \"display\": \"<string>\"\n },\n \"messages\": [\n {\n \"content\": \"<string>\"\n }\n ],\n \"tools\": [\n {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"input_schema\": {\n \"type\": \"<string>\"\n }\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.usehasp.com/v1/ai/chat")
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 \"message\": \"<string>\",\n \"model\": \"<string>\",\n \"conversation_id\": \"<string>\",\n \"stream\": true,\n \"store\": true,\n \"system\": \"<string>\",\n \"tool_choice\": \"<string>\",\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 \"subject\": {\n \"type\": \"<string>\",\n \"id\": \"<string>\"\n },\n \"on_behalf_of\": {\n \"id\": \"<string>\",\n \"display\": \"<string>\"\n },\n \"messages\": [\n {\n \"content\": \"<string>\"\n }\n ],\n \"tools\": [\n {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"input_schema\": {\n \"type\": \"<string>\"\n }\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"id": "<string>",
"model": "<unknown>",
"role": "<string>",
"content": [
{
"type": "<string>",
"text": "<string>"
}
],
"stop_reason": "<string>",
"usage": "<string>"
},
"meta": {
"request_id": "<string>"
}
}{
"success": false,
"error": {
"type": "authentication",
"code": "INVALID_API_KEY",
"message": "Bearer token is missing, malformed, or revoked.",
"param": null,
"details": null,
"retryable": false,
"request_id": "01JQREQ7XZQK5N6PZ1VVXHYB8T"
},
"meta": {
"request_id": "01JQREQ7XZQK5N6PZ1VVXHYB8T"
}
}{
"message": "<string>"
}{
"success": true,
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"param": "<string>",
"details": "<string>",
"retryable": true,
"request_id": "<string>"
},
"meta": {
"request_id": "<string>"
},
"errors": "<string>"
}{
"message": "<string>",
"errors": {}
}{
"success": false,
"error": {
"type": "rate_limited",
"code": "RATE_LIMITED",
"message": "Rate limit exceeded (per-key, per-org, or daily cap, depending on which limiter tripped).",
"param": null,
"details": null,
"retryable": true,
"request_id": "01JQREQ7XZQK5N6PZ1VVXHYB8T"
},
"meta": {
"request_id": "01JQREQ7XZQK5N6PZ1VVXHYB8T"
}
}{
"success": true,
"error": {
"code": "<string>",
"message": "<string>"
}
}Run HASP's native chat completion for the caller's org
Streams by default, or returns the assembled response.
curl --request POST \
--url https://api.usehasp.com/v1/ai/chat \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"message": "<string>",
"model": "<string>",
"conversation_id": "<string>",
"stream": true,
"store": true,
"system": "<string>",
"tool_choice": "<string>",
"top_p": 0.5,
"top_k": 2,
"provider_extensions": [
"<string>"
],
"stop_sequences": [
"<string>"
],
"metadata": {
"user_id": "<string>"
},
"subject": {
"type": "<string>",
"id": "<string>"
},
"on_behalf_of": {
"id": "<string>",
"display": "<string>"
},
"messages": [
{
"content": "<string>"
}
],
"tools": [
{
"name": "<string>",
"description": "<string>",
"input_schema": {
"type": "<string>"
}
}
]
}
'import requests
url = "https://api.usehasp.com/v1/ai/chat"
payload = {
"message": "<string>",
"model": "<string>",
"conversation_id": "<string>",
"stream": True,
"store": True,
"system": "<string>",
"tool_choice": "<string>",
"top_p": 0.5,
"top_k": 2,
"provider_extensions": ["<string>"],
"stop_sequences": ["<string>"],
"metadata": { "user_id": "<string>" },
"subject": {
"type": "<string>",
"id": "<string>"
},
"on_behalf_of": {
"id": "<string>",
"display": "<string>"
},
"messages": [{ "content": "<string>" }],
"tools": [
{
"name": "<string>",
"description": "<string>",
"input_schema": { "type": "<string>" }
}
]
}
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({
message: '<string>',
model: '<string>',
conversation_id: '<string>',
stream: true,
store: true,
system: '<string>',
tool_choice: '<string>',
top_p: 0.5,
top_k: 2,
provider_extensions: ['<string>'],
stop_sequences: ['<string>'],
metadata: {user_id: '<string>'},
subject: {type: '<string>', id: '<string>'},
on_behalf_of: {id: '<string>', display: '<string>'},
messages: [{content: '<string>'}],
tools: [{name: '<string>', description: '<string>', input_schema: {type: '<string>'}}]
})
};
fetch('https://api.usehasp.com/v1/ai/chat', 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/ai/chat",
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([
'message' => '<string>',
'model' => '<string>',
'conversation_id' => '<string>',
'stream' => true,
'store' => true,
'system' => '<string>',
'tool_choice' => '<string>',
'top_p' => 0.5,
'top_k' => 2,
'provider_extensions' => [
'<string>'
],
'stop_sequences' => [
'<string>'
],
'metadata' => [
'user_id' => '<string>'
],
'subject' => [
'type' => '<string>',
'id' => '<string>'
],
'on_behalf_of' => [
'id' => '<string>',
'display' => '<string>'
],
'messages' => [
[
'content' => '<string>'
]
],
'tools' => [
[
'name' => '<string>',
'description' => '<string>',
'input_schema' => [
'type' => '<string>'
]
]
]
]),
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/ai/chat"
payload := strings.NewReader("{\n \"message\": \"<string>\",\n \"model\": \"<string>\",\n \"conversation_id\": \"<string>\",\n \"stream\": true,\n \"store\": true,\n \"system\": \"<string>\",\n \"tool_choice\": \"<string>\",\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 \"subject\": {\n \"type\": \"<string>\",\n \"id\": \"<string>\"\n },\n \"on_behalf_of\": {\n \"id\": \"<string>\",\n \"display\": \"<string>\"\n },\n \"messages\": [\n {\n \"content\": \"<string>\"\n }\n ],\n \"tools\": [\n {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"input_schema\": {\n \"type\": \"<string>\"\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/ai/chat")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"message\": \"<string>\",\n \"model\": \"<string>\",\n \"conversation_id\": \"<string>\",\n \"stream\": true,\n \"store\": true,\n \"system\": \"<string>\",\n \"tool_choice\": \"<string>\",\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 \"subject\": {\n \"type\": \"<string>\",\n \"id\": \"<string>\"\n },\n \"on_behalf_of\": {\n \"id\": \"<string>\",\n \"display\": \"<string>\"\n },\n \"messages\": [\n {\n \"content\": \"<string>\"\n }\n ],\n \"tools\": [\n {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"input_schema\": {\n \"type\": \"<string>\"\n }\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.usehasp.com/v1/ai/chat")
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 \"message\": \"<string>\",\n \"model\": \"<string>\",\n \"conversation_id\": \"<string>\",\n \"stream\": true,\n \"store\": true,\n \"system\": \"<string>\",\n \"tool_choice\": \"<string>\",\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 \"subject\": {\n \"type\": \"<string>\",\n \"id\": \"<string>\"\n },\n \"on_behalf_of\": {\n \"id\": \"<string>\",\n \"display\": \"<string>\"\n },\n \"messages\": [\n {\n \"content\": \"<string>\"\n }\n ],\n \"tools\": [\n {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"input_schema\": {\n \"type\": \"<string>\"\n }\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"id": "<string>",
"model": "<unknown>",
"role": "<string>",
"content": [
{
"type": "<string>",
"text": "<string>"
}
],
"stop_reason": "<string>",
"usage": "<string>"
},
"meta": {
"request_id": "<string>"
}
}{
"success": false,
"error": {
"type": "authentication",
"code": "INVALID_API_KEY",
"message": "Bearer token is missing, malformed, or revoked.",
"param": null,
"details": null,
"retryable": false,
"request_id": "01JQREQ7XZQK5N6PZ1VVXHYB8T"
},
"meta": {
"request_id": "01JQREQ7XZQK5N6PZ1VVXHYB8T"
}
}{
"message": "<string>"
}{
"success": true,
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"param": "<string>",
"details": "<string>",
"retryable": true,
"request_id": "<string>"
},
"meta": {
"request_id": "<string>"
},
"errors": "<string>"
}{
"message": "<string>",
"errors": {}
}{
"success": false,
"error": {
"type": "rate_limited",
"code": "RATE_LIMITED",
"message": "Rate limit exceeded (per-key, per-org, or daily cap, depending on which limiter tripped).",
"param": null,
"details": null,
"retryable": true,
"request_id": "01JQREQ7XZQK5N6PZ1VVXHYB8T"
},
"meta": {
"request_id": "01JQREQ7XZQK5N6PZ1VVXHYB8T"
}
}{
"success": true,
"error": {
"code": "<string>",
"message": "<string>"
}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
Validates POST /v1/ai/chat per PRD §05-public-api.
HASP-509: extended from a single-turn message field to a full superset —
messages[] history (same content-block dialect Anthropic-compat uses, so
AnthropicMessagesRequestBuilder is reused verbatim for both), tools, and
the full cross-provider parameter set (top_p/top_k/tool_choice/
metadata/stop_sequences). message (singular) is preserved as shorthand
for a single user-turn request — exactly one of message/messages must
be present.
100000100Either a bare ULID (the pre-existing passthrough tag) or a
conv_-prefixed id naming a server-owned conversation
(ADR-AHK8YT). Validated as a pattern rather than ulid so the
prefixed form is not rejected before the controller can resolve
it; which of the two it is decides whether the call is stateful.
^(conv_)?[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$10000InferenceRequest's canonical vocabulary directly: 'auto'|'any'| 'none'| — no compat-surface wire shape to normalize.
0 <= x <= 1x >= 1Escape hatch for provider-specific wire keys the canonical fields above don't (yet) model — see ADR-ZP99PX.
Show child attributes
Show child attributes
PRD-phi-reidentification-map §8: contextual subject binding for the
audit row fidelity layer. Optional everywhere — when present, both
type and id must be set (rule required_with on each side).
Show child attributes
Show child attributes
Asserted end-user identity: which user of your application took
this action. Recorded on the audit chain as an assertion made by
your integration — HASP does not verify it, and it is never
shown to the model. Distinct from subject, which names who or
what the action is about. id is your stable identifier for
the person; display is an optional human-readable name shown
to audit reviewers. Supported for API-key credentials only.
Show child attributes
Show child attributes
1Show child attributes
Show child attributes
App-domain tool shape — no wire-format translation needed since this is HASP's own surface, not a compat passthrough.
Show child attributes
Show child attributes