Skip to main content
OpenAI Chat Completions-compatible endpoint. Coding agents, IDE integrations, and any code built against the 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

Never silently dropped. temperature, top_p, stop, and tool_choice are applied to the model request. If the model’s provider cannot honor one you set, the request fails with 400 UNSUPPORTED_PARAMETER naming it. n, frequency_penalty, and presence_penalty have no equivalent in HASP’s inference request: their neutral values (n: 1, 0, 0) are accepted so default SDK payloads work, and any other value is rejected with 400 UNSUPPORTED_PARAMETER. Unlike the native /v1/ai/chat endpoint, stream defaults to false here, matching OpenAI’s default.

Model selection

The model 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

When stream is omitted or false, the response is a single chat.completion object:
When the model calls a tool, message.content is null and message.tool_calls carries the calls; finish_reason is tool_calls.

Streaming response (SSE)

When stream: 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:
The first chunk carries the assistant role, content deltas stream in the middle, a penultimate chunk sets 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. In redact mode PHI is replaced with placeholders before the upstream call; in block mode the request is rejected.
  • BAA required. No active BAA → a permission_error with hasp_code BAA_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 error type 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.