Create a chat completion
POST/v1/chat/completions
The HackAgent LLM gateway, in OpenAI's chat completions format: point an OpenAI client at https://api.hackagent.dev/v1 with a HackAgent API key. model picks one of HackAgent's models (GET /v1/models): hackagent/attacker-v1, which writes adversarial prompts, or hackagent/judge-v1, which judges responses. The response names that model only, never the upstream one.
Each call is charged to the organization's credits: its maximum cost (from max_tokens, capped at the model's limit) must be covered by the balance (402 otherwise), and its actual cost is deducted after it succeeds and logged (GET /apilogs). Streaming is not available (stream: true answers 501). Accepts an API key, a login token, or a cloud run's token, whose calls are charged to the run's organization. Errors use the gateway's own shape, {"error": ..., "code": ...}.
Request
Responses
- 200
- 400
- 401
- 402
- 403
- 429
- 500
- 501
- 502
- 504
OK
Invalid body: not JSON, an unknown model (UNKNOWN_MODEL) or an invalid max_tokens (INVALID_MAX_TOKENS).
Missing, invalid, expired or revoked credential, or a credential this endpoint does not accept.
Not enough credits for the call (INSUFFICIENT_CREDITS).
The caller has no organization to charge (gateway shape, code: ORG_CONTEXT_MISSING), or the API refused the call before the gateway ({"detail": ...}): the credential may not call it, or the installation is read-only (code: license_read_only).
Retry after Retry-After seconds: the model provider is busy (gateway shape, code: PROVIDER_RATE_LIMITED), or the caller exceeded the API's rate limit ({"detail": ...}).
The gateway is misconfigured or failed unexpectedly.
Streaming was requested (STREAMING_DISABLED).
The model provider could not be reached or failed.
The model provider timed out.