---
title: "Audit LLM call after completion"
method: POST
path: "/api/audit/llm-call"
tags: ["Gateway Mode"]
---

# Audit LLM call after completion

`POST /api/audit/llm-call`

## Request

- Base URL: `https://agent.getaxonflow.com`
- URL: `https://agent.getaxonflow.com/api/audit/llm-call`
- Auth: none declared. Required headers: `Authorization`
- TypeScript: <https://skmtc.dev/getaxonflow/apis/axonflow-agent-api/docs/api/audit/llm-call/post.ts> (a function with typed inputs; its response is checked against the schema)

Gateway Mode Step 2: Call this endpoint after your LLM API call completes.

Records:
- Token usage for billing and quotas
- Latency metrics
- Provider and model information
- Estimated cost

**Requires a valid context_id from pre-check (not expired).**

## Headers

- `Authorization` string, required

## Request body

- AuditLLMCallRequest
  - `context_id` string, required: Context ID from pre-check
  - `client_id` string, required: Client application ID
  - `response_summary` string: Brief summary of LLM response (for audit)
  - `provider` 'openai' | 'azure-openai' | 'anthropic' | 'bedrock' | 'ollama' | 'gemini', required: LLM provider name
  - `model` string, required: Model identifier
  - `token_usage` TokenUsage, required
    - `prompt_tokens` integer: Tokens in the prompt
    - `completion_tokens` integer: Tokens in the completion
    - `total_tokens` integer: Total tokens used
  - `latency_ms` integer: LLM call latency in milliseconds
  - `metadata` object: Additional metadata for audit

## Response `200`

Audit recorded

- AuditLLMCallResponse
  - `success` boolean
  - `audit_id` string: Unique audit record ID

## Other responses

- `400`: Invalid or expired context
- `401`: Missing or invalid authentication. Handler-written 401s use the `{success, error}` envelope; 401s written by the auth middleware use the `{"error": {"code", "message"}}` envelope (JSONError).

---

[API](https://skmtc.dev/getaxonflow/apis/axonflow-agent-api.md) - [All operations](https://skmtc.dev/getaxonflow/apis/axonflow-agent-api/llms.txt) - [OpenAPI document](https://skmtc.dev/getaxonflow/apis/axonflow-agent-api/revisions/34d30fcb7fa1?raw)
