> ## Documentation Index
> Fetch the complete documentation index at: https://docs.case.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# SDKs

> Official client libraries for the Case.dev API

Official client libraries for integrating Case.dev into your application.

## Available SDKs

We provide official SDKs for the following languages:

* **[TypeScript / JavaScript](#typescript)** - For Node.js, Deno, Bun, and browsers
* **[Python](#python)** - Synchronous and async support
* **[Go](#go)** - Full type-safe Go SDK

All SDKs are type-safe, well-documented, and maintained automatically from our OpenAPI specification.

***

## TypeScript

[![npm](https://img.shields.io/npm/v/casedev.svg)](https://npmjs.org/package/casedev)

### Installation

```bash title="Shell" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
npm install casedev
```

### Quick Start

```typescript title="Typescript" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
import Casedev from 'casedev';

const client = new Casedev({
  apiKey: process.env.CASEDEV_API_KEY,
  environment: 'production' // or 'local' for development
});

// Create a vault
const vault = await client.vault.create({
  name: 'My Documents',
  description: 'Legal document repository'
});

// Chat with an LLM
const response = await client.llm.v1.chat.createCompletion({
  model: 'anthropic/claude-3-5-sonnet-20241022',
  messages: [
    { role: 'user', content: 'Summarize this contract...' }
  ]
});
```

### Features

* Full TypeScript support with type inference
* Promise-based async API
* Automatic retries with exponential backoff
* Streaming support for real-time responses
* Works in Node.js, Deno, Bun, and browsers

### Repository

[github.com/CaseMark/casedev-typescript](https://github.com/CaseMark/casedev-typescript)

***

## Python

[![PyPI](https://img.shields.io/pypi/v/casedev.svg)](https://pypi.org/project/casedev/)

### Installation

```bash title="Shell" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
pip install casedev
```

### Quick Start

```python title="Python" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
from casedev import Casedev

client = Casedev(
    api_key="sk_case_...",
    environment="production"  # or "local"
)

# Create a vault
vault = client.vault.create(
    name="My Documents",
    description="Legal document repository"
)

# Chat with an LLM
response = client.llm.v1.chat.create_completion(
    model="anthropic/claude-3-5-sonnet-20241022",
    messages=[
        {"role": "user", "content": "Summarize this contract..."}
    ]
)

print(response.choices[0].message.content)
```

### Async Support

```python title="Python" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
from casedev import AsyncCasedev
import asyncio

async def main():
    async with AsyncCasedev(api_key="sk_case_...") as client:
        response = await client.llm.v1.chat.create_completion(
            messages=[{"role": "user", "content": "Hello!"}]
        )
        print(response.choices[0].message.content)

asyncio.run(main())
```

### Features

* Full type hints with modern Python
* Synchronous and asynchronous clients
* aiohttp support for better async performance
* Automatic retries and error handling
* Python 3.9+ support

### Repository

[github.com/CaseMark/casedev-python](https://github.com/CaseMark/casedev-python)

***

## Go

### Installation

```bash title="Shell" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
go get -u github.com/CaseMark/casedev-go
```

Requires Go 1.22+.

### Quick Start

```go title="Go" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
package main

import (
	"context"
	"fmt"

	casedev "github.com/CaseMark/casedev-go"
	"github.com/CaseMark/casedev-go/option"
)

func main() {
	client := casedev.NewClient(
		option.WithAPIKey("sk_case_YOUR_API_KEY"),        // or set CASEDEV_API_KEY env var
		option.WithEnvironmentProduction(),                // default
	)

	// Create a vault
	vault, _ := client.Vault.New(context.TODO(), casedev.VaultNewParams{
		Name:        casedev.F("My Documents"),
		Description: casedev.F("Legal document repository"),
	})

	// Chat with an LLM
	resp, _ := client.Llm.V1.Chat.NewCompletion(context.TODO(), casedev.LlmV1ChatNewCompletionParams{
		Model: casedev.F("anthropic/claude-sonnet-4.5"),
		Messages: casedev.F([]casedev.LlmV1ChatNewCompletionParamsMessage{{
			Role:    casedev.F(casedev.LlmV1ChatNewCompletionParamsMessagesRoleUser),
			Content: casedev.F("Summarize this contract..."),
		}}),
	})

	fmt.Println(resp.Choices[0].Message.Content)
}
```

### Features

* Full type safety with Go generics
* Automatic retries with exponential backoff (2 retries by default)
* Configurable via `option.With*` helpers
* Environment variable auto-detection (`CASEDEV_API_KEY`)
* Raw HTTP response access via `option.WithResponseInto`

### Repository

[github.com/CaseMark/casedev-go](https://github.com/CaseMark/casedev-go)

***

## Authentication

All SDKs require an API key from the [Case.dev dashboard](https://app.case.dev).

```bash title="Shell" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
# Set as environment variable
export CASEDEV_API_KEY=sk_case_...
```

The Go SDK automatically reads the `CASEDEV_API_KEY` environment variable. No additional configuration is needed.

API keys starting with `sk_case_` are production keys. Development keys are available for testing.

### Scoped Permissions

API keys can be scoped to specific services with read or write access. If your key lacks permission for a service, you'll receive a `403 Forbidden` error. Check your key's permissions in the dashboard.

## Error Handling

All SDKs provide typed error classes for handling API errors:

<CodeGroup>
  ```typescript title="Typescript" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  try {
    await client.vault.retrieve('invalid-id');
  } catch (error) {
    if (error instanceof Casedev.NotFoundError) {
      console.log('Vault not found:', error.status);
    }
  }
  ```

  ```python title="Python" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  from casedev import NotFoundError

  try:
      client.vault.retrieve('invalid-id')
  except NotFoundError as e:
      print(f'Vault not found: {e.status}')
  ```

  ```go title="Go" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  import (
  	"errors"
  	casedev "github.com/CaseMark/casedev-go"
  )

  vault, err := client.Vault.Get(context.TODO(), "invalid-id")
  if err != nil {
  	var apierr *casedev.Error
  	if errors.As(err, &apierr) {
  		fmt.Println("Status:", apierr.StatusCode) // 404
  	}
  }
  ```
</CodeGroup>

## Rate Limits

All API requests are subject to rate limits based on your plan. SDKs automatically handle rate limit responses with exponential backoff retries.

## Support

* **Documentation:** [docs.case.dev](https://docs.case.dev)
* **Email:** [support@casemark.com](mailto:support@casemark.com)
* **Community:** [case.dev/slack](https://case.dev/slack)
* **GitHub Issues:** Report SDK bugs in the respective repository

## Open Source

All SDKs are open source under the Apache 2.0 license. Contributions are welcome!

***

## Next Steps

<CardGroup>
  <Card title="Getting Started" href="/getting-started">
    Integration tutorials with step-by-step examples
  </Card>

  <Card title="Services Catalog" href="/services">
    Browse all available services
  </Card>

  <Card title="Cookbooks" href="/cookbooks">
    Reference implementations and architecture patterns
  </Card>
</CardGroup>
