feat(fal_client): add a tags request option - #1158
Open
dazip wants to merge 1 commit into
Open
Conversation
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>
tags request optiontags request option
dazip
marked this pull request as ready for review
September 7, 2026 21:49
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why: callers want to attach their own
key=valuetags to fal requests so usage and cost can be attributed to their own dimensions (team, environment, feature). The gateway already parses and stamps the packedX-Fal-Tagsheader; the Python client had no way to send it.Adds a
tags=option torun,submit,subscribe, andstreamon bothSyncClientandAsyncClient(and therefore the module-levelfal_client.run/submit/... aliases). Tags are packed into a singleX-Fal-Tags: k=v,k=vheader by a newadd_tags_headerhelper 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 reservedfal.*namespace refused. The gateway fails open and silently drops pairs it rejects, so the client raisesValueErrorup front instead.Note
Low Risk
Additive optional parameter and request-header validation only; no changes to auth, billing logic, or existing call paths when
tagsis omitted.Overview
Adds optional
tags=onrun,submit,subscribe, andstreamforSyncClientandAsyncClient, 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, nofal.*keys), then sent as a singleX-Fal-Tags: key=value,...header. Invalid tags raiseValueErrorbefore 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
subscribeforwarding tosubmit).Reviewed by Cursor Bugbot for commit 4cbc0a3. Bugbot is set up for automated code reviews on this repo. Configure here.