Skip to content

Commit 43c8e51

Browse files
shawnfeldmanclaude
andauthored
feat: add --inference flag to token create command to create bearer tokens usable in the inference gateway (#773)
* feat: add --inference flag to token create command Adds support for generating access tokens with InferenceGrant, matching the token generation logic used in agent-gateway for AI/inference endpoint authentication. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: print full ClaimGrants struct instead of just VideoGrant Addresses review feedback to show all grant types (inference, identity, etc.) in the "Token grants:" output, not just the video grant. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * chore: bump version to 2.14.0 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e7da75d commit 43c8e51

2 files changed

Lines changed: 19 additions & 3 deletions

File tree

cmd/lk/token.go

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ const (
3939
usageAdmin = "Ability to moderate a room (requires --room)"
4040
usageEgress = "Ability to interact with Egress services"
4141
usageIngress = "Ability to interact with Ingress services"
42-
usageMetadata = "Ability to update their own name and metadata"
42+
usageMetadata = "Ability to update their own name and metadata"
43+
usageInference = "Ability to perform inference (AI endpoints)"
4344
)
4445

4546
var (
@@ -82,6 +83,10 @@ var (
8283
Name: "ingress",
8384
Usage: usageIngress,
8485
},
86+
&cli.BoolFlag{
87+
Name: "inference",
88+
Usage: usageInference,
89+
},
8590
&cli.BoolFlag{
8691
Name: "allow-update-metadata",
8792
Usage: usageMetadata,
@@ -287,6 +292,10 @@ func createToken(ctx context.Context, c *cli.Command) error {
287292
grant.IngressAdmin = true
288293
hasPerms = true
289294
}
295+
inferenceGrant := c.Bool("inference")
296+
if inferenceGrant {
297+
hasPerms = true
298+
}
290299
if c.IsSet("allow-source") {
291300
sourcesStr := c.StringSlice("allow-source")
292301
sources := make([]livekit.TrackSource, 0, len(sourcesStr))
@@ -329,6 +338,7 @@ func createToken(ctx context.Context, c *cli.Command) error {
329338
pAdmin
330339
pEgress
331340
pIngress
341+
pInference
332342
pMetadata
333343
)
334344

@@ -343,6 +353,7 @@ func createToken(ctx context.Context, c *cli.Command) error {
343353
huh.NewOption("Admin", pAdmin),
344354
huh.NewOption("Egress", pEgress),
345355
huh.NewOption("Ingress", pIngress),
356+
huh.NewOption("Inference", pInference),
346357
huh.NewOption("Update metadata", pMetadata),
347358
).
348359
Title("Token Permissions").
@@ -362,6 +373,7 @@ func createToken(ctx context.Context, c *cli.Command) error {
362373
grant.RoomRecord = true
363374
}
364375
grant.SetCanUpdateOwnMetadata(slices.Contains(permissions, pMetadata))
376+
inferenceGrant = slices.Contains(permissions, pInference)
365377
}
366378
}
367379

@@ -372,6 +384,10 @@ func createToken(ctx context.Context, c *cli.Command) error {
372384

373385
at := accessToken(project.APIKey, project.APISecret, grant, participant)
374386

387+
if inferenceGrant {
388+
at.SetInferenceGrant(&auth.InferenceGrant{Perform: true})
389+
}
390+
375391
if grant.RoomJoin {
376392
if agent := c.String("agent"); agent != "" {
377393
jobMetadata := c.String("job-metadata")
@@ -413,7 +429,7 @@ func createToken(ctx context.Context, c *cli.Command) error {
413429
}
414430

415431
fmt.Println("Token grants:")
416-
util.PrintJSON(grant)
432+
util.PrintJSON(at.GetGrants())
417433
fmt.Println()
418434
if project.URL != "" {
419435
fmt.Println("Project URL:", project.URL)

version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
package livekitcli
1616

1717
const (
18-
Version = "2.13.2"
18+
Version = "2.14.0"
1919
)

0 commit comments

Comments
 (0)