---
title: "AISIX 1.7.1: Make Cross-Provider Stream Usage an Explicit Contract - API7.ai"
description: "Learn how AISIX 1.7.1 handles requested streaming usage and what to check before upgrading."
url: "https://api7.ai/blog/aisix-1-7-1-stream-usage-contract"
---

[Blog](https://api7.ai/blog)

[Products](https://api7.ai/category/products)[Technology](https://api7.ai/category/technology)[Ecosystem](https://api7.ai/category/ecosystem)[Case Study](https://api7.ai/category/usercase)[Team & Community](https://api7.ai/category/community)

Search

⌘ + K

[Blog](https://api7.ai/blog)

Products

# AISIX 1.7.1: Make Cross-Provider Stream Usage an Explicit Contract

October 27, 2026

[Products](https://api7.ai/category/products)

Streaming clients often treat the final chat-completion frame as a convenient place to collect token usage. That works only until a provider reports usage on a different event—or a gateway makes one provider's behavior look like a portable contract.

[AISIX 1.7.1](https://github.com/api7/aisix/releases/tag/v1.7.1), released October 27, 2026, changes how `/v1/chat/completions` streams expose `stream_options.include_usage` across supported upstreams. For a stream that completes without an error and has a usage report, AISIX prepares a usage-only chunk after the other chunks when the client requests it. A client that does not ask receives no usage in stream chunks. This response change does not itself change AISIX usage events, TPM limits, or billing.

Application code can decide whether it needs stream usage and parse the terminal shape when a report is available. An interrupted or failed stream, an upstream that provides no usage report, or an output guardrail that blocks held content may prevent that chunk from reaching the client. The accompanying 1.7.1 parameter changes address a separate compatibility question: whether a target platform accepts a field a caller sends.

## The Upgrade Risk: Usage Was Not Previously Portable

Before 1.7.1, some upstreams exposed usage on their finish event even when the caller had not requested `include_usage`. That meant a client could appear to work with one provider while depending on a response detail that was absent—or differently timed—on another.

After the upgrade, request usage deliberately when the client consumes it:

```
{
  "model": "your-model",
  "stream": true,
  "stream_options": { "include_usage": true },
  "messages": [{ "role": "user", "content": "Summarize this report." }]
}
```

When a stream finishes without error and the gateway has a usage report, AISIX emits a usage-only chunk with an empty `choices` array after the other chunks. In a local test using AISIX 1.7.1 and a simulated OpenAI-compatible upstream, the final portion was:

```
data: {"choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}

data: {"choices":[],"usage":{"prompt_tokens":21,"completion_tokens":5,"total_tokens":26}}
```

These excerpts omit envelope fields from the actual gateway response for readability; the upstream and token counts were simulated. They show the response shape for this completed test, not a provider charge or a guarantee for interrupted streams.

Do not assume that an event with `finish_reason` also has `usage`; in this contract, the usage-only chunk follows it. Conversely, when `include_usage` is omitted or `false`, no response chunk carries `usage`. AISIX can still record gateway usage for its own observability and controls; that recording is separate from what a streaming caller receives.

## Build One Consumer Path for Every Supported Upstream

This change helps teams route an OpenAI-shaped client through Claude, Vertex Gemini, and OpenAI-compatible targets. Their upstream event formats differ; when a terminal usage report is available, callers can consume the normalized shape.

Use a consumer path that does three things:

1. Render deltas while `choices` contains content.
2. Treat a chunk with a finish reason as completion of generated content, not as the usage record.
3. When usage is requested and a usage-only chunk arrives, read it where `choices` is empty; handle its absence on errors, disconnects, missing upstream usage, or a guardrail block.

The tagged AISIX 1.7.1 E2E test exercises this with mocked Anthropic, Vertex Claude, Vertex Gemini, and OpenAI-compatible streams. In those test cases, each returns one usage-only terminal chunk with the same reported totals, while a request without `include_usage` exposes no usage chunk. The test also checks an adapter boundary: the OpenAI-compatible target receives `stream_options`, while the three mocked Claude and Gemini paths do not receive that OpenAI-specific field.

This is not a claim that all streaming behavior is identical. Content cadence, provider stop conditions, model availability, and upstream token reporting remain provider-specific. Applications that need an accounting decision should also keep gateway-recorded usage distinct from a provider invoice.

## Audit the Compatibility Change Separately

AISIX 1.7.1 also changes how some request fields are handled. The release notes describe cases where values are forwarded in the target's form and an upstream rejection is surfaced. Mappings and omissions depend on the adapter and request: for example, the Anthropic adapter drops `tool_choice` when no tool survives translation. Validate each path rather than assuming every documented field is forwarded.

That difference is visible during an upgrade. A request that relied on the gateway silently dropping a field can now receive an upstream `400`. The release notes call out examples including `stop` for some Bedrock models, `temperature`, `top_p`, or `logprobs` for a reasoning GPT on Bedrock, a tool `strict` value unsupported by a model, and a Gemini 2.5 thinking budget above the model ceiling.

Use this pre-production check for every provider/model pair that matters to an application:

1. Send the application's actual streaming request with `include_usage: true` when it reads usage.
2. Inventory optional parameters, especially sampling, stop, structured-output, tool, and reasoning fields.
3. Confirm the target model documents each field and its allowed values.
4. Test the failure response as well as the success response; an upstream `400` is now an expected compatibility signal, not necessarily a gateway regression.

Do not generalize from one bridge to all targets. AISIX still drops OpenAI-only fields on Claude chat where sending them would cause an Anthropic error, and each provider adapter has its own documented mappings and limits.

For current product and deployment context, see the [AISIX AI Gateway overview](https://api7.ai/ai-gateway); its current capabilities are separate from the version-specific changes discussed here.

## Keep Rolling Upgrades Safe

The release notes include one shared-cache constraint. During a rolling upgrade or rollback, a 1.7.1 gateway can write a response-cache entry that has multiple choices or `logprobs`; a 1.7.0-or-earlier gateway sharing that cache cannot read that entry and reports a cache error. Other cache entries are unaffected.

Plan the upgrade around that boundary:

- Identify mixed-version gateways that share a response cache.
- Exercise a representative multi-choice or `logprobs` request before allowing old and new gateways to share the cache.
- Coordinate rollback criteria with the cache behavior, not only with deployment health.
- Update stream consumers before expecting usage in the terminal response path.

AISIX 1.7.1 lets streaming clients request a consistent usage-only terminal shape when a report is available. Handle missing usage on failed or interrupted streams and guardrail blocks. Review the [full release and upgrade notes](https://github.com/api7/aisix/releases/tag/v1.7.1) before deploying, and validate each provider/model parameter set in a non-production environment.

Tags:

[AISIX](https://api7.ai/tags/aisix)

[AI Gateway](https://api7.ai/tags/ai-gateway)

[LLM Observability](https://api7.ai/tags/llm-observability)

Share article link

Share

Related Posts

[![AISIX 1.8.0: Keep Budget Decisions Local During Control-Plane Outages](https://static.api7.ai/uploads/2026/11/26/XbgyaY5o_aisix-1-8-0-local-budget-decisions.webp)](https://api7.ai/blog/aisix-1-8-0-local-budget-decisions)

## [AISIX 1.8.0: Keep Budget Decisions Local During Control-Plane Outages](https://api7.ai/blog/aisix-1-8-0-local-budget-decisions)

[![AISIX 1.7.0: Turn AI Spend Into an Operating Boundary](https://static.api7.ai/uploads/2026/10/26/qZ0mRtyd_aisix-1-7-0-cost-attribution-tags.webp)](https://api7.ai/blog/aisix-1-7-0-cost-attribution-tags)

## [AISIX 1.7.0: Turn AI Spend Into an Operating Boundary](https://api7.ai/blog/aisix-1-7-0-cost-attribution-tags)

Table of Contents

- [The Upgrade Risk: Usage Was Not Previously Portable](#the-upgrade-risk-usage-was-not-previously-portable)
- [Build One Consumer Path for Every Supported Upstream](#build-one-consumer-path-for-every-supported-upstream)
- [Audit the Compatibility Change Separately](#audit-the-compatibility-change-separately)
- [Keep Rolling Upgrades Safe](#keep-rolling-upgrades-safe)

## Related Posts

[![AISIX 1.11.0: Migrate File-Based Gateway Configuration Safely](https://static.api7.ai/uploads/2026/11/24/b8SCADQk_aisix-1-11-0-file-configuration-migration.webp)](https://api7.ai/blog/aisix-1-11-0-file-configuration-migration)

Products

November 20, 2026

#### [AISIX 1.11.0: Migrate File-Based Gateway Configuration Safely](https://api7.ai/blog/aisix-1-11-0-file-configuration-migration)

Discover how AISIX 1.11.0 makes file-based configuration easier to migrate, validate, and troubleshoot before rollout.

[AISIX](https://api7.ai/tags/aisix)

[AI Gateway](https://api7.ai/tags/ai-gateway)

[![AISIX 1.10.0: Keep AI Coding Sessions on a Matched Semantic Route](https://static.api7.ai/uploads/2026/11/13/5rPD4mvs_aisix-1-10-0-semantic-routing-session-affinity.webp)](https://api7.ai/blog/aisix-1-10-0-semantic-routing-session-affinity)

Products

November 12, 2026

#### [AISIX 1.10.0: Keep AI Coding Sessions on a Matched Semantic Route](https://api7.ai/blog/aisix-1-10-0-semantic-routing-session-affinity)

AISIX 1.10.0 brings semantic routing to Messages and Responses APIs, model-group targets, and optional session affinity for supported AI coding and agent sessions.

[AISIX](https://api7.ai/tags/aisix)

[AI Gateway](https://api7.ai/tags/ai-gateway)

[Semantic Routing](https://api7.ai/tags/semantic-routing)

[![AISIX 1.9.0: Connect MCP Users with Their Own Upstream Authorization](https://static.api7.ai/uploads/2026/11/12/HBiZRdR1_aisix-1-9-0-per-user-mcp-oauth.webp)](https://api7.ai/blog/aisix-1-9-0-per-user-mcp-oauth)

Products

November 6, 2026

#### [AISIX 1.9.0: Connect MCP Users with Their Own Upstream Authorization](https://api7.ai/blog/aisix-1-9-0-per-user-mcp-oauth)

AISIX 1.9.0 adds per-user upstream MCP OAuth, allowing users to authorize an upstream service from their MCP client while AISIX manages the upstream credentials.

[AISIX](https://api7.ai/tags/aisix)

[AI Gateway](https://api7.ai/tags/ai-gateway)

[MCP](https://api7.ai/tags/mcp)
