Skip to content

[OPIK-6049] [SDK][FE] feat: add --workspace and --api-key to opik connect/endpoint CLI#6364

Merged
itamargolan merged 4 commits intomainfrom
itamar/OPIK-6049-connect-cli-workspace-apikey
Apr 20, 2026
Merged

[OPIK-6049] [SDK][FE] feat: add --workspace and --api-key to opik connect/endpoint CLI#6364
itamargolan merged 4 commits intomainfrom
itamar/OPIK-6049-connect-cli-workspace-apikey

Conversation

@itamargolan
Copy link
Copy Markdown
Contributor

@itamargolan itamargolan commented Apr 17, 2026

Details

Add --workspace and --api-key as inline options on both connect and endpoint CLI subcommands, so users can run a single command instead of exporting environment variables:

# Before
export OPIK_API_KEY="..."
export OPIK_WORKSPACE="..."
opik connect --project "Test"

# After
opik connect --project "Test" --workspace "my-ws" --api-key "my-key"

Precedence:

  • --api-key: local subcommand option > global opik --api-key > OPIK_API_KEY env > config file
  • --workspace: local subcommand option > OPIK_WORKSPACE env > config file > "default"

Config persistence: If ~/.opik.config doesn't exist after successful pairing, it is auto-saved so first-time users get a config file automatically. Also fixes a bug where project_name was not forwarded to the Opik() constructor, causing the config to save "Default Project" instead of the user-specified project.

Frontend: Updated the Get Started page to show the new single-command format with the full API key visible (no masking). Removed redundant copyText prop.

All new options default to None, so existing invocations are fully backward-compatible.

Change checklist

  • My change requires a change to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • Existing unit tests pass locally with my changes

Issues

Resolves OPIK-6049

Testing

  • 17 CLI unit tests pass (6 new tests for workspace/api-key forwarding and precedence)
  • TypeScript compiles cleanly with no errors
  • Existing tests unaffected (backward compatible)
  • Manually tested live pairing flow against cloud backend

Documentation

No documentation changes required. The CLI --help output automatically reflects the new flags.

…nect/endpoint CLI

Add --workspace and --api-key as inline options on both connect and
endpoint subcommands so users can run a single command instead of
exporting environment variables first.

Precedence: local --api-key > global --api-key > OPIK_API_KEY env > config.
Workspace: local --workspace > OPIK_WORKSPACE env > config > "default".

Also auto-creates ~/.opik.config on first use if it doesn't exist, and
updates the frontend Get Started page to show the new single-command
format with the full API key visible.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions github-actions bot added python Pull requests that update Python code Frontend tests Including test files, or tests related like configuration. typescript *.ts *.tsx Python SDK labels Apr 17, 2026
@github-actions
Copy link
Copy Markdown
Contributor

📋 PR Linter Failed

Missing Section. The description is missing the ## Change checklist section.


Missing Section. The description is missing the ## Documentation section.

Comment thread sdks/python/src/opik/cli/_run.py Outdated
Comment thread sdks/python/src/opik/cli/connect.py
… pairing

The CLI's run_cli_session was not forwarding the --project flag to the
Opik() constructor, causing ~/.opik.config to save "Default Project"
instead of the user-specified project name. Also moves config file
persistence to after successful pairing so a failed connection doesn't
write a config file. Removes redundant copyText prop from CodeSnippet.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Comment thread sdks/python/src/opik/cli/_run.py Outdated
itamargolan and others added 2 commits April 20, 2026 08:47
Users should be aware when their config file fails to persist after
a successful pairing, otherwise they silently lose their settings.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@itamargolan itamargolan marked this pull request as ready for review April 20, 2026 12:27
@itamargolan itamargolan requested a review from a team as a code owner April 20, 2026 12:27
Comment on lines +33 to +34
if api_key:
ctx.obj["api_key"] = api_key
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The connect and endpoint guards that set ctx.obj['api_key'] from --api-key duplicate the same plumbing, should we extract it into a shared helper like store_api_key(ctx, api_key) or centralize before run_cli_session?

Finding type: Code Dedup and Conventions | Severity: 🟢 Low


Want Baz to fix this for you? Activate Fixer

Copy link
Copy Markdown
Collaborator

@alexkuzmik alexkuzmik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SDK part looks good.

Copy link
Copy Markdown
Collaborator

@aadereiko aadereiko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FE part looks good!

@itamargolan itamargolan merged commit 7682948 into main Apr 20, 2026
108 of 136 checks passed
@itamargolan itamargolan deleted the itamar/OPIK-6049-connect-cli-workspace-apikey branch April 20, 2026 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Frontend Python SDK python Pull requests that update Python code tests Including test files, or tests related like configuration. typescript *.ts *.tsx

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants