From 9272fb1d22ae98c8c19081081c46909f1e1b98a3 Mon Sep 17 00:00:00 2001 From: Shawn Feldman Date: Fri, 27 Feb 2026 09:40:19 -0700 Subject: [PATCH] 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 --- cmd/lk/token.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/cmd/lk/token.go b/cmd/lk/token.go index d176e112..e09a08a4 100644 --- a/cmd/lk/token.go +++ b/cmd/lk/token.go @@ -39,7 +39,8 @@ const ( usageAdmin = "Ability to moderate a room (requires --room)" usageEgress = "Ability to interact with Egress services" usageIngress = "Ability to interact with Ingress services" - usageMetadata = "Ability to update their own name and metadata" + usageMetadata = "Ability to update their own name and metadata" + usageInference = "Ability to perform inference (AI endpoints)" ) var ( @@ -82,6 +83,10 @@ var ( Name: "ingress", Usage: usageIngress, }, + &cli.BoolFlag{ + Name: "inference", + Usage: usageInference, + }, &cli.BoolFlag{ Name: "allow-update-metadata", Usage: usageMetadata, @@ -287,6 +292,10 @@ func createToken(ctx context.Context, c *cli.Command) error { grant.IngressAdmin = true hasPerms = true } + inferenceGrant := c.Bool("inference") + if inferenceGrant { + hasPerms = true + } if c.IsSet("allow-source") { sourcesStr := c.StringSlice("allow-source") sources := make([]livekit.TrackSource, 0, len(sourcesStr)) @@ -329,6 +338,7 @@ func createToken(ctx context.Context, c *cli.Command) error { pAdmin pEgress pIngress + pInference pMetadata ) @@ -343,6 +353,7 @@ func createToken(ctx context.Context, c *cli.Command) error { huh.NewOption("Admin", pAdmin), huh.NewOption("Egress", pEgress), huh.NewOption("Ingress", pIngress), + huh.NewOption("Inference", pInference), huh.NewOption("Update metadata", pMetadata), ). Title("Token Permissions"). @@ -362,6 +373,7 @@ func createToken(ctx context.Context, c *cli.Command) error { grant.RoomRecord = true } grant.SetCanUpdateOwnMetadata(slices.Contains(permissions, pMetadata)) + inferenceGrant = slices.Contains(permissions, pInference) } } @@ -372,6 +384,10 @@ func createToken(ctx context.Context, c *cli.Command) error { at := accessToken(project.APIKey, project.APISecret, grant, participant) + if inferenceGrant { + at.SetInferenceGrant(&auth.InferenceGrant{Perform: true}) + } + if grant.RoomJoin { if agent := c.String("agent"); agent != "" { jobMetadata := c.String("job-metadata")