openai SDK need only change the baseURL — request shape, response shape, and streaming chunks are OpenAI’s exact wire format. Requires the ai:chat scope.
This surface is stateless: it never persists conversation content and does not accept a conversation_id. Audit events are still written for every request. If you need stored conversations, run management, or PHI entity metadata, use the native POST /v1/ai/chat.
Migrating from OpenAI
Request
Body parameters
Accepted but ignored.
top_p, n, frequency_penalty, presence_penalty, stop, and user are validated for shape (so existing SDK payloads don’t error) but do not affect inference — HASP’s inference request does not model them.
Unlike the native /v1/ai/chat endpoint, stream defaults to false here, matching OpenAI’s default.
Model selection
Themodel field takes a HASP registry model id, not the provider’s public name. The same identifiers work on every HASP surface:
There is no requirement to pick an OpenAI model on this surface — you can drive a Claude model through the OpenAI wire format. Premium models require org enablement; a request for a model your org has not enabled returns a
400 invalid_request_error with hasp_code MODEL_ACCESS_DENIED. See Model Selection for cost/access details.
Non-streaming response
Whenstream is omitted or false, the response is a single chat.completion object:
message.content is null and message.tool_calls carries the calls; finish_reason is tool_calls.
Streaming response (SSE)
Whenstream: true, the response is a text/event-stream of chat.completion.chunk objects in OpenAI’s exact format — the same shape the openai SDK’s streaming iterator expects:
finish_reason, a final chunk carries usage, and the stream terminates with data: [DONE]. Tool calls stream as delta.tool_calls[] entries with a stable zero-based index.
Compliance behavior
All HASP compliance checks apply — PHI Guard, BAA enforcement, and credit metering — identically to every other surface. Compliance is a property of your organization, not the endpoint shape.- PHI Guard runs on all messages per your org’s
phi_mode. Inredactmode PHI is replaced with placeholders before the upstream call; inblockmode the request is rejected. - BAA required. No active BAA → a
permission_errorwithhasp_codeBAA_REQUIRED. - Credit metering. Credits are deducted after each successful response.
Errors
Errors are returned in OpenAI’s error envelope. HASP’s richer error vocabulary maps into OpenAI’s errortype set, with the original HASP code preserved as code (lowercased) and hasp_code:
During a stream, a mid-run failure is emitted as a terminal
data: line carrying the same error envelope rather than an HTTP status change.