Skip to content

feat(client-tokens): support ephemeral keys v2 - #40

Merged
AdirAmsalem merged 2 commits into
mainfrom
ephemeral-keys-v2
Mar 22, 2026
Merged

AdirAmsalem merged 2 commits into
mainfrom
ephemeral-keys-v2

Conversation

@AdirAmsalem

@AdirAmsalem AdirAmsalem commented Mar 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add expires_in, allowed_models, and constraints optional parameters to tokens.create()
  • Add permissions and constraints optional fields to CreateTokenResponse
  • New TokenConstraints, RealtimeConstraints, and TokenPermissions TypedDicts for type safety
  • All new fields are optional — fully backward compatible

Usage

from decart import DecartClient

client = DecartClient(api_key="sk_...")

# Basic usage (unchanged)
token = await client.tokens.create()

# With expiry and model restrictions
token = await client.tokens.create(
    expires_in=120,  # seconds (1-3600, default 60)
    allowed_models=["lucy_2_rt", "mirage_v2"],
    constraints={"realtime": {"maxSessionDuration": 300}},
    metadata={"user_id": "abc123"},
)

print(token.api_key)        # "ek_..."
print(token.expires_at)     # "2026-03-22T09:18:00Z"
print(token.permissions)    # {"models": ["lucy_2_rt", "mirage_v2"]}
print(token.constraints)    # {"realtime": {"maxSessionDuration": 300}}

Test plan

  • All 9 token tests pass (uv run pytest tests/test_tokens.py -v)
  • Manual verification against live API with v2 fields

🤖 Generated with Claude Code

AdirAmsalem and others added 2 commits March 22, 2026 11:15
Add expiresIn, allowedModels, and constraints to the create token
request, and permissions/constraints to the response. All new fields
are optional for backward compatibility.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Also fix black formatting in test file.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@AdirAmsalem AdirAmsalem changed the title feat: support ephemeral keys v2 in tokens client feat(client-tokens): support ephemeral keys v2 Mar 22, 2026
@AdirAmsalem
AdirAmsalem merged commit cef0227 into main Mar 22, 2026
8 checks passed
@AdirAmsalem
AdirAmsalem deleted the ephemeral-keys-v2 branch March 22, 2026 12:42
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