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.
- 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
- TypeScript SDK package on npm (@slinear/sdk)
Key Capabilities
- Prompt LibraryAvailable now- Versioned prompts with status lifecycle, tags, and required variables
- LLM GatewayAvailable now- OpenAI-compatible chat completions with provider routing
- Provider KeysAvailable now- Manage OpenAI, Anthropic, and Groq API keys per workspace
- Usage & ActivityAvailable now- Dashboard endpoints for stats, activity, and usage
- Access ControlAvailable now- Workspace and application roles (viewer to owner)
- TypeScript SDKPublishing 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
pnpm add @slinear/sdk2. Initialize the Client
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
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
const prompt = await client.promptLibrary.getLatest({
applicationSlug,
slug: "summarizer",
});
console.log(prompt.content);
// Output: "Summarize the following text: {{text}}"5. Call the LLM Gateway
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 keyssk_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
- Navigate to Settings > SLinear API Keys in the dashboard
- Click "Create API Key"
- Choose the key scope (User or Application)
- Set an optional expiration date
- 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/sdkClient 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 versionsclient.prompts- Prompt operations by IDclient.chatCompletions- LLM Gateway chat completionsclient.providerKeys- Provider API key managementclient.llmRequests- LLM request logsclient.dashboard- Usage stats and activityclient.approvalChains- Approval chains for prompt changesclient.applications- Applications and membershipsclient.workspaces- Workspaces and membershipsclient.users- Workspace users and rolesclient.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:
| Role | Permissions |
|---|---|
| Viewer | Read-only access to workspace and application resources |
| Editor | Create/edit prompts and use the LLM Gateway |
| Admin | Manage applications, API keys, provider keys, and roles |
| Owner | Full 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
- Go to Settings > Team in the dashboard
- Click "Invite Member"
- Enter their email address
- Select a role
- They'll receive an email invitation to join