Skip to content

feat(fal_client): add a tags request option - #1158

Open
dazip wants to merge 1 commit into
mainfrom
prod-4145-fal-python-tags-request-option
Open

feat(fal_client): add a tags request option#1158
dazip wants to merge 1 commit into
mainfrom
prod-4145-fal-python-tags-request-option

Conversation

@dazip

@dazip dazip commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Why: callers want to attach their own key=value tags to fal requests so usage and cost can be attributed to their own dimensions (team, environment, feature). The gateway already parses and stamps the packed X-Fal-Tags header; the Python client had no way to send it.

Adds a tags= option to run, submit, subscribe, and stream on both SyncClient and AsyncClient (and therefore the module-level fal_client.run/submit/... aliases). Tags are packed into a single X-Fal-Tags: k=v,k=v header by a new add_tags_header helper in _headers.py, which validates them the way the gateway does — keys lowercased and limited to [a-z0-9._-], values printable ASCII without commas, at most 10 pairs, 64-char keys, 256-char values, 1 KB of keys and values, and the reserved fal.* namespace refused. The gateway fails open and silently drops pairs it rejects, so the client raises ValueError up front instead.


Note

Low Risk
Additive optional parameter and request-header validation only; no changes to auth, billing logic, or existing call paths when tags is omitted.

Overview
Adds optional tags= on run, submit, subscribe, and stream for SyncClient and AsyncClient, so callers can attach custom dimensions (team, env, feature) for usage attribution.

Tags are validated client-side in new add_tags_header (limits and rules aligned with the gateway: key format, printable ASCII values, max pairs/lengths, 1 KB budget, no fal.* keys), then sent as a single X-Fal-Tags: key=value,... header. Invalid tags raise ValueError before any HTTP call, instead of being silently dropped server-side.

Unit tests cover header packing/validation and that tagged requests set the header on sync/async paths (including subscribe forwarding to submit).

Reviewed by Cursor Bugbot for commit 4cbc0a3. Bugbot is set up for automated code reviews on this repo. Configure here.

Adds tags= on run/submit/subscribe/stream for both clients, packed into one X-Fal-Tags header, with client-side validation mirroring the gateway.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@linear-code

linear-code Bot commented Sep 4, 2026

Copy link
Copy Markdown

PROD-4145

@dazip dazip changed the title PROD-4145: fal (Python): tags request option feat(fal_client): add a tags request option Sep 4, 2026
@dazip
dazip marked this pull request as ready for review September 7, 2026 21:49

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing blocking. The comments below are optional suggestions. There is no need to push a fix for them before merging.

Comment thread projects/fal_client/src/fal_client/_headers.py
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.

1 participant