feat(cli): add ogx connect claude command#5877
Conversation
Add a new CLI subcommand that launches Claude Code connected to a running OGX server, handling model discovery, tier mapping, and environment variable configuration automatically. The command probes the server for available LLM models, maps them to Claude's haiku/sonnet/opus tiers, and launches claude with the appropriate ANTHROPIC_BASE_URL and model tier env vars set. Includes --print-env flag for shell integration and per-tier model overrides. Updates Claude Code integration docs to use the new command as the primary quick-start workflow. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> Signed-off-by: Nathan Weinberg <[email protected]>
mattf
left a comment
There was a problem hiding this comment.
$ uv run ogx connect claude
INFO 2026-05-18T15:04:53.726819Z ogx.cli.connect.claude:135 Connecting to Claude Code
base_url=http://localhost:8321 category=cli haiku=claude-haiku-4-5 models=6 opus=claude-haiku-4-5
sonnet=claude-haiku-4-5
▐▛███▜▌ Claude Code v2.1.143
▝▜█████▛▘ Haiku 4.5 (1M context) · API Usage Billing
▘▘ ▝▝ ~/Documents/Repositories/meta-llama/llama-stack
Opus 4.7 xhigh is now available! · /model to switch
❯ hello
⎿ Not logged in · Please run /login
✻ Worked for 0s
❯ /model
────────────────────────────────────────────────────────────────────────────────────────────────────────
Select model
Switch between Claude models. Applies to this session and future Claude Code sessions. For
other/previous model names, specify with --model.
❯ 1. Default (recommended) ✔ Use the default model (currently Haiku 4.5 (1M context)) · $5/$25 per
Mtok
2. claude-haiku-4-5 Custom Opus model
3. claude-haiku-4-5 Custom Sonnet model
4. claude-haiku-4-5 Custom Haiku model
○ Effort not supported for Default (recommended)
something is missing
|
Did it work after you logged in? Maybe we just need to make that a prereq |
i don't have a login to use. i expect if you're logging in then you aren't using stack. |
Nope, you can be logged in and not be using Anthropic models |
an anthropic account should not be required if we're going to claim you can use claude cli w/ stack |
…laude Code gateway auth ANTHROPIC_API_KEY requires an interactive approval prompt on first use in Claude Code, which causes "Not logged in" errors for users who haven't previously authenticated. ANTHROPIC_AUTH_TOKEN is the documented approach for LLM gateways and proxies — it sends a Bearer token with no approval flow required. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> Signed-off-by: Nathan Weinberg <[email protected]>
that's progress. it's weird that consider - |
that's probably if no models are specified at launch with the CLI it will set the first available model as the default for all so a user you can either
|
|
I believe the |
mattf
left a comment
There was a problem hiding this comment.
$ curl -s http://localhost:8321/v1/models | jq -r '.data[].id'
claude-haiku-4-5
claude-sonnet-4-6
claude-opus-4-7
$ uv run ogx connect claude --print-env
export ANTHROPIC_BASE_URL=http://localhost:8321
export ANTHROPIC_AUTH_TOKEN=ogx
export ANTHROPIC_DEFAULT_HAIKU_MODEL=claude-haiku-4-5
export ANTHROPIC_DEFAULT_SONNET_MODEL=claude-haiku-4-5
export ANTHROPIC_DEFAULT_OPUS_MODEL=claude-haiku-4-5
unset CLAUDE_CODE_USE_VERTEX
unset ANTHROPIC_VERTEX_PROJECT_ID
unset CLAUDE_CODE_USE_BEDROCK
unset ANTHROPIC_BEDROCK_SESSION_TOKEN
instead of using the first model for all the defaults, what do you think about doing a simple check to populate the default models based on what's available?
… claude` Replace --host/--port with --url to support https and custom ports without extra flags. Auto-detect haiku/sonnet/opus tier mappings from available model names instead of defaulting all tiers to the first model. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> Signed-off-by: Nathan Weinberg <[email protected]>
f06965c to
9f52a06
Compare
mattf
left a comment
There was a problem hiding this comment.
looking good. one question about the base url.
cdoern
left a comment
There was a problem hiding this comment.
one change but its pretty important
Signed-off-by: Nathan Weinberg <[email protected]>
02c4e7f to
1340ac3
Compare
What does this PR do?
Add a new CLI subcommand that launches Claude Code connected to a running OGX server, handling model discovery, tier mapping, and environment variable configuration automatically. The command probes the server for available LLM models, maps them to Claude's haiku/sonnet/opus tiers, and launches claude with the appropriate ANTHROPIC_BASE_URL and model tier env vars set. Includes --print-env flag for shell integration and per-tier model overrides. Updates Claude Code integration docs to use the new command as the primary quick-start workflow.
Closes #5870
Test Plan
Unit tests added, manual test steps below (non-destructive for those with existing Claude setups)