Skip to content

feat: add optional compression fields to completion requests#7

Merged
CLEMENTINATOR merged 9 commits intomainfrom
add-compression-fields
Feb 4, 2026
Merged

feat: add optional compression fields to completion requests#7
CLEMENTINATOR merged 9 commits intomainfrom
add-compression-fields

Conversation

@CLEMENTINATOR
Copy link
Member

Summary

  • Add optional enable_compression: bool | None field to InputObject dataclass
  • Add optional compression_rate: float | None field to InputObject dataclass
  • Include compression fields in request body when provided via InputObject or dict input
  • Compression fields are omitted from request when not provided
  • Fields are gateway-internal and not sent to providers

Test plan

  • Verify compression fields are included in request body when provided
  • Verify compression fields are omitted when not provided
  • Test with InputObject and dict inputs

🤖 Generated with Claude Code

@CLEMENTINATOR CLEMENTINATOR requested a review from a team as a code owner February 3, 2026 16:56
@SachaMorard
Copy link
Member

@CLEMENTINATOR Do you want to add the compression response field in another PR?

@CLEMENTINATOR CLEMENTINATOR force-pushed the add-compression-fields branch from 2035793 to 774142f Compare February 4, 2026 15:08
CLEMENTINATOR and others added 9 commits February 4, 2026 16:40
Add support for compression configuration with optional fields that can be
passed per request to override API key settings.

- Add optional `enable_compression: bool | None` field to `InputObject` dataclass
- Add optional `compression_rate: float | None` field to `InputObject` dataclass
- Include compression fields in request body when provided via InputObject or dict input
- Compression fields are omitted from request when not provided
- Fields are gateway-internal and not sent to providers

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add Compression dataclass with input_tokens, saved_tokens, and rate fields
- Add optional compression field to SendResponse for root-level compression data
- Add test for response with compression field
- Add test for response without compression field
- Update _handle_non_streaming_response to parse compression data
- Add example showing how to access compression data in responses
- Add compression info to features list
- Add example showing how to enable compression and set compression rate
- Demonstrate accessing compression metrics from response
- Show usage information alongside compression data
- Add substantial AI history document as context (~3000+ chars)
- Demonstrate meaningful compression on large input
- Show percentage of tokens saved
- Explain that compression works on input tokens
- Only USER messages are compressed, not system messages
- Update example to put context in user message
- Add clarifying comment about compression behavior
@CLEMENTINATOR CLEMENTINATOR force-pushed the add-compression-fields branch from eb1f82a to f4e9f2b Compare February 4, 2026 15:40
@CLEMENTINATOR CLEMENTINATOR merged commit bc6b6fd into main Feb 4, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants