Skip to content

Latest commit

 

History

History
130 lines (92 loc) · 3.69 KB

File metadata and controls

130 lines (92 loc) · 3.69 KB

Scope SDK

Official SDK clients for the Scope Platform.

Available SDKs

Language Package Status
Ruby scope-client Available
Python scope-client Available
Node.js @scope/client Coming Soon
Java/JVM io.scope:scope-client Coming Soon

Overview

Scope SDKs provide read-only access to the Scope Platform, enabling you to:

  • Fetch production and draft prompts
  • Render prompts with variable substitution
  • Cache prompts for performance
  • Integrate with your LLM workflows

Quick Start

Python

Install from git (not yet published to PyPI):

pip install git+https://github.com/base14/scope-sdk.git#subdirectory=sdks/python
from scope_client import ScopeClient, ApiKeyCredentials

# Create credentials from environment variables
credentials = ApiKeyCredentials.from_env()
# Or explicitly:
# credentials = ApiKeyCredentials(
#     org_id="my-org",
#     api_key="key_abc123",
#     api_secret="secret_xyz"
# )

# Create a client
client = ScopeClient(credentials=credentials)

# Fetch and render a prompt (defaults to production version)
version = client.get_prompt_version("my-prompt")
rendered = version.render(customer_name="Alice", product="Widget")

# Access prompt metadata (model config, etc.)
model = version.get_metadata("model")  # e.g., "gpt-4"
temperature = version.get_metadata("temperature", 0.7)  # with default

Ruby

Add to your Gemfile (not yet published to RubyGems):

gem 'scope-client', git: 'https://github.com/base14/scope-sdk.git', glob: 'sdks/ruby/*.gemspec'
require 'scope_client'

# Create credentials from environment variables
credentials = ScopeClient::Credentials::ApiKey.from_env
# Or explicitly:
# credentials = ScopeClient::Credentials::ApiKey.new(
#   org_id: 'my-org',
#   api_key: 'key_abc123',
#   api_secret: 'secret_xyz'
# )

# Configure globally
ScopeClient.configure do |config|
  config.credentials = credentials
end

# Create a client
client = ScopeClient.client

# Fetch and render a prompt (defaults to production version)
version = client.get_prompt_version('my-prompt')
rendered = version.render(customer_name: 'Alice', product: 'Widget')

# Access prompt metadata (model config, etc.)
model = version.get_metadata('model')  # e.g., 'gpt-4'
temperature = version.get_metadata('temperature', 0.7)  # with default

Authentication

All SDKs use JWT-based authentication with an extensible credentials system. The primary authentication method uses client credentials.

Credentials

Authentication requires three values:

  1. Organization ID (SCOPE_ORG_ID): Your organization identifier
  2. Client ID (SCOPE_CLIENT_ID): Your application client ID
  3. Client Secret (SCOPE_CLIENT_SECRET): Your application client secret

These can be loaded from environment variables using ClientCredentials.from_env() (Python) or Credentials::ApiKey.from_env (Ruby), or passed directly when creating credentials.

Generate credentials from the Scope UI under Settings > Applications.

Backward compatibility: The old environment variable names (SCOPE_API_KEY, SCOPE_API_SECRET) and parameter names (api_key, api_secret) are still supported but deprecated.

Environment Variables

export SCOPE_ORG_ID="my-org"
export SCOPE_CLIENT_ID="key_abc123"
export SCOPE_CLIENT_SECRET="secret_xyz"
export SCOPE_API_URL="https://api.scope.io"
export SCOPE_AUTH_API_URL="https://auth.scope.io"

Documentation

License

MIT. See LICENSE.