client

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 13, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFromContext

func NewFromContext(cmd *cobra.Command) (*sdkclient.Client, error)

NewFromContext creates an SDK client from CLI context.

Credential resolution order (first match wins):

  1. --public-key + --secret-key flags (both required together)
  2. --api-key pk_…:sk_… flag (deprecated; emits stderr warning)
  3. PROMPTVM_PUBLIC_KEY + PROMPTVM_SECRET_KEY env vars (silent)
  4. PROMPTVM_API_KEY=pk_…:sk_… env var (silent backward-compat)
  5. Active profile (api-key)
  6. Active profile (OAuth)

For OAuth profiles the access token is loaded from the keychain and auto-refreshed if it has expired.

Types

type Credentials

type Credentials struct {
	PublicKey   string
	SecretKey   string
	BearerToken string

	// Organization is the org UUID recorded on the profile the bearer
	// token came from. Sent as X-Org-Id so org-scoped routes (api-keys,
	// settings, billing) can resolve the active org for CLI sessions.
	// Empty for api-key credentials — the backend derives the org from
	// the key itself.
	Organization string
}

Credentials holds a resolved api-key credential pair, or — for OAuth profiles — a single bearer token. Exactly one of (PublicKey, SecretKey) or BearerToken is set.

func ResolveCredentials

func ResolveCredentials(cmd *cobra.Command) (Credentials, error)

ResolveCredentials walks the precedence table and returns either a (publicKey, secretKey) pair or a bearer token. Exposed for testing.

func (Credentials) IsAPIKey

func (c Credentials) IsAPIKey() bool

IsAPIKey reports whether the credential is a dual-header api-key pair.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL