SLinear Documentation

SLinear is an API-first platform for prompt versioning and multi-provider chat completions. It includes workspace/application management, API keys, provider keys, and usage tracking for LLM requests.

Documentation scope

These docs describe what is implemented in the current codebase. If something is not released yet, it is explicitly labeled.

Available now
Live in the current release
  • Workspace and application management
  • Prompt library with versioning and status lifecycle
  • LLM Gateway chat completions (OpenAI-compatible)
  • Provider API keys (OpenAI, Anthropic, Groq)
  • Dashboard stats, activity, and usage endpoints
  • Approval chains for prompt changes
Publishing soon
SDK release
  • TypeScript SDK package on npm (@slinear/sdk)

Key Capabilities

  • Prompt Library
    Available now
    - Versioned prompts with status lifecycle, tags, and required variables
  • LLM Gateway
    Available now
    - OpenAI-compatible chat completions with provider routing
  • Provider Keys
    Available now
    - Manage OpenAI, Anthropic, and Groq API keys per workspace
  • Usage & Activity
    Available now
    - Dashboard endpoints for stats, activity, and usage
  • Access Control
    Available now
    - Workspace and application roles (viewer to owner)
  • TypeScript SDK
    Publishing soon
    - NPM package: @slinear/sdk

Who is SLinear for?

  • AI Engineers building agents in TypeScript or Python
  • Platform Teams providing governance and usage visibility
  • Product Teams needing reliable prompt management and LLM routing

Quickstart

Get started with SLinear in under 5 minutes.

Before you start

Create a workspace, an application, and a SLinear API key in the dashboard. Use an application-scoped key if you want usage attributed to a specific application.

Prerequisites

  • Node.js 18+ (or any runtime with fetch)
  • SLinear API key (sk_test_ or sk_live_)
  • An application ID from your workspace

1. Install the SDK

Terminalbash
pnpm add @slinear/sdk

2. Initialize the Client

src/lib/slinear.tstypescript
import { SLinearClient } from "@slinear/sdk";

const client = new SLinearClient({
  baseUrl: "https://api.slinear.com",
  apiKey: process.env.SLINEAR_API_KEY,
});

API Keys

Get your API key from Settings > SLinear API Keys. Use application-scoped keys when you want usage attributed to a specific application.

3. Select an Application

src/example.tstypescript
const applications = await client.applications.list();
	const application = applications[0];

	if (!application) {
	  throw new Error("No applications found.");
	}

const applicationSlug = application.slug;

4. Fetch a Prompt

src/example.tstypescript
const prompt = await client.promptLibrary.getLatest({
  applicationSlug,
  slug: "summarizer",
});

console.log(prompt.content);
// Output: "Summarize the following text: {{text}}"

5. Call the LLM Gateway

src/example.tstypescript
const completion = await client.chatCompletions.createChatCompletion({
  createChatCompletionRequest: {
    model: "gpt-4o-mini",
    messages: [
      { role: "system", content: prompt.content },
      { role: "user", content: "Hello, world!" },
    ],
  },
});

console.log(completion.choices[0]?.message?.content);

Core Concepts

Understanding the SLinear data model and hierarchy.

Workspaces

A Workspace is the top-level container representing your organization or team. All resources (applications, prompts, API keys) belong to a workspace. Workspaces provide multi-tenant isolation and have their own member list. Most API endpoints use the workspace ID; slugs are for display.

Applications

Applications are project namespaces within a workspace. Use them to organize prompts and track usage per project. For example, you might have separate applications for "customer-support-bot" and "code-review-assistant". API calls typically reference an applicationSlug.

Prompts

Prompts are versioned templates stored in the prompt library. Each prompt has:

  • Slug for prompt family identification
  • Content with variable placeholders (e.g., {{text}})
  • Version number (v1, v2, etc.)
  • Status (Draft, Active, Archived)
  • Tags for organization

API Keys

API Keys authenticate requests to the SLinear API. There are two types:

  • User-scoped keys - Access based on the user's permissions
  • Application-scoped keys - Limited to a specific application and used for usage attribution

Prompt Library

The Prompt Library stores versioned prompt templates with tags, metadata, and required variables.

Creating a Prompt

const prompt = await client.promptLibrary.createPrompt({
  applicationSlug,
  createPromptRequest: {
    slug: "customer-support-response",
    content: `You are a helpful customer support agent.

Customer query: {{query}}

Respond professionally and concisely.`,
    tags: ["support", "customer-facing"],
  },
});

Version Management

Every prompt edit creates a new immutable version. Versions are numbered sequentially (v1, v2, v3...).

// Create a draft version
const draft = await client.promptLibrary.createPromptVersion({
  applicationSlug,
  slug: "customer-support-response",
  createPromptVersionRequest: {
    content: "Updated prompt content...",
    status: "draft",
  },
});

// Activate the new version
await client.promptLibrary.activatePromptVersion({
  applicationSlug,
  slug: "customer-support-response",
  version: draft.version,
});

Status Lifecycle

Prompts follow a lifecycle with three statuses:

  • Draft - Work in progress, safe for iteration
  • Active - Production ready, returned by getLatest()
  • Archived - Deprecated, kept for history

Only One Active Version

Only one version of a prompt can be Active at a time. Activating a new version automatically archives the previous active version.

Variables

Use double curly braces for variable placeholders. SLinear automatically detects required variables and lets you override them if needed.

// Prompt content with variables
const content = `Translate the following {{source_language}} text to {{target_language}}:

{{text}}`;

// SLinear detects: ["source_language", "target_language", "text"]

LLM Gateway

The LLM Gateway exposes an OpenAI-compatible /v1/chat/completions endpoint with routing to OpenAI, Anthropic, and Groq.

Model format

Use OpenAI model IDs directly (for example, gpt-4o-mini) or prefix non-OpenAI models with the provider (for example, anthropic/claude-3-5-sonnet or groq/llama-3.1-70b).

Supported Providers

  • OpenAI
  • Anthropic
  • Groq

Provider Keys

Configure your LLM provider API keys in Settings > Provider API Keys. Keys are encrypted at rest.

Chat Completions

The chat completions endpoint is OpenAI-compatible, making it easy to migrate existing code.

const completion = await client.chatCompletions.createChatCompletion({
  createChatCompletionRequest: {
    model: "gpt-4o-mini",
    messages: [
      { role: "system", content: "You are a helpful assistant." },
      { role: "user", content: "What is the capital of France?" },
    ],
    temperature: 0.7,
    maxTokens: 500,
  },
});

console.log(completion.choices[0]?.message?.content);
// "The capital of France is Paris."

Streaming Responses

Streaming uses Server-Sent Events (SSE). Use the OpenAI SDK to consume streaming responses.

import OpenAI from "openai";

const openai = new OpenAI({
  apiKey: process.env.SLINEAR_API_KEY,
  baseURL: "https://api.slinear.com",
});

const stream = await openai.chat.completions.create({
  model: "gpt-4o-mini",
  messages: [{ role: "user", content: "Tell me a story." }],
  stream: true,
  stream_options: { include_usage: true },
});

for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}

Token Tracking

Every request returns token usage metadata. Expanded dashboard views for usage and activity are available via the dashboard API.

// Response includes usage information
console.log(completion.usage);
// { promptTokens: 25, completionTokens: 12, totalTokens: 37 }

Authentication

Authenticate API requests using API keys (recommended) or Stytch session cookies for browser-based access.

API Key Authentication

API keys are the recommended method for server-side applications. Keys use the following prefixes:

  • sk_test_ - Test environment keys
  • sk_live_ - Production environment keys
// Using API key with the SDK
const client = new SLinearClient({
  baseUrl: "https://api.slinear.com",
  apiKey: "sk_live_your_api_key_here",
});

// Or via HTTP header
fetch("https://api.slinear.com/api/me", {
  headers: {
    "Authorization": "Bearer sk_live_your_api_key_here",
  },
});

Keep Keys Secure

Never expose API keys in client-side code or commit them to version control. Use environment variables instead.

Creating API Keys

  1. Navigate to Settings > SLinear API Keys in the dashboard
  2. Click "Create API Key"
  3. Choose the key scope (User or Application)
  4. Set an optional expiration date
  5. Copy the key immediately - it won't be shown again

Key Revocation

Revoke compromised keys immediately from the dashboard. Revoked keys become invalid instantly.

TypeScript SDK

The official TypeScript SDK provides a type-safe client for the SLinear API.

SDK availability

The TypeScript SDK will be published to npm shortly as @slinear/sdk. The examples below reflect the current API surface.

Installation

pnpm add @slinear/sdk

Client Configuration

import { SLinearClient } from "@slinear/sdk";

const client = new SLinearClient({
  baseUrl: "https://api.slinear.com",
  apiKey: process.env.SLINEAR_API_KEY,
  // Optional: custom fetch implementation
  // fetch: customFetch,
});

Available APIs

The SDK exposes the following API clients:

  • client.promptLibrary - Prompt library and versions
  • client.prompts - Prompt operations by ID
  • client.chatCompletions - LLM Gateway chat completions
  • client.providerKeys - Provider API key management
  • client.llmRequests - LLM request logs
  • client.dashboard - Usage stats and activity
  • client.approvalChains - Approval chains for prompt changes
  • client.applications - Applications and memberships
  • client.workspaces - Workspaces and memberships
  • client.users - Workspace users and roles
  • client.me, client.app, client.health, client.feedback - Utility APIs

Error Handling

import { ResponseError } from "@slinear/sdk";

try {
  const prompt = await client.promptLibrary.getLatest({
    applicationSlug,
    slug: "nonexistent",
  });
} catch (error) {
  if (error instanceof ResponseError) {
    const details = await error.response.json();
    console.error("API Error:", error.response.status, details);
  }
  throw error;
}

Access Control

SLinear uses Role-Based Access Control (RBAC) to manage permissions across workspaces and applications.

Role enforcement

Workspace and application roles are enforced on API endpoints for sensitive reads and all write operations.

Roles

There are four roles with increasing levels of access:

RolePermissions
ViewerRead-only access to workspace and application resources
EditorCreate/edit prompts and use the LLM Gateway
AdminManage applications, API keys, provider keys, and roles
OwnerFull access, including destructive actions

Workspace vs Application Membership

Members can have different roles at workspace and application levels:

  • Workspace membership - Grants default access to all applications
  • Application membership - Overrides the workspace role for that application

If a user has no application membership, their workspace role applies.

Least Privilege

Follow the principle of least privilege. Grant users the minimum role needed for their tasks.

Inviting Team Members

  1. Go to Settings > Team in the dashboard
  2. Click "Invite Member"
  3. Enter their email address
  4. Select a role
  5. They'll receive an email invitation to join