> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.joytokens.ai/llms.txt.

# Quickstart

> Make your first JoyToken request with a client SDK in 3 steps

Get a single request running end-to-end. For the full catalog of runnable snippets (streaming, Anthropic, model list, error handling), see [Examples](/client-sdk/examples).

## Prerequisites

| Item         | Value                                                                  |
| ------------ | ---------------------------------------------------------------------- |
| API key      | `JOY_TOKEN_API_KEY`                                                    |
| API Base URL | `JOY_TOKEN_API_BASE_URL` from [Environments](/user-guide/environments) |
| Model        | `auto` (not configurable)                                              |
| TypeScript   | Node.js `18+`                                                          |
| Go           | Go `1.22+`                                                             |

## Step 1: Set the environment

```bash
export JOY_TOKEN_API_KEY="sk-xxx"
export JOY_TOKEN_OPENAI_BASE_URL="https://api.joytokens.ai/openai/v1"
```

Both SDKs default to a 60-second request/stream timeout. Override it only when a workload needs a different limit �?TypeScript `timeoutMs`, Go `WithTimeout`.

## Step 2: Install

#### TypeScript

TypeScript is distributed from GitHub, not the npm registry. Add the package subdirectory to `package.json`:

```json
{
  "type": "module",
  "dependencies": {
    "@joytoken/client-sdk-ts": "git+https://github.com/jd-opensource/joytoken-sdk-ts.git#path:/client-sdk-ts"
  }
}
```

```bash
pnpm install
```

Pin a release tag or commit for reproducible builds instead of following the default branch.

#### Go

```bash
go get github.com/jd-opensource/joytoken-sdk-go
```

Pin a release tag for reproducible production builds.

## Step 3: Make your first request

#### TypeScript

```ts
import { JoyTokenClient } from "@joytoken/client-sdk-ts";

const apiKey = process.env.JOY_TOKEN_API_KEY;
if (!apiKey) throw new Error("JOY_TOKEN_API_KEY is required");

const joytoken = new JoyTokenClient({
  apiKey,
  openAIBaseUrl: process.env.JOY_TOKEN_OPENAI_BASE_URL,
});

const completion = await joytoken.chat.completions.create({
  model: "auto",
  messages: [{ role: "user", content: "Reply with exactly: pong" }],
});

console.log(completion.choices[0]?.message?.content);
```

#### Go

```go
package main

import (
    "context"
    "fmt"
    "os"

    joytoken "github.com/jd-opensource/joytoken-sdk-go"
)

func main() {
    ctx := context.Background()
    client := joytoken.NewClient(
        joytoken.WithAPIKey(os.Getenv("JOY_TOKEN_API_KEY")),
        joytoken.WithOpenAIBaseURL(os.Getenv("JOY_TOKEN_OPENAI_BASE_URL")),
    )

    completion, err := client.CreateChatCompletion(ctx, joytoken.ChatCompletionRequest{
        Model:    joytoken.ModelAuto,
        Messages: []joytoken.ChatMessage{{Role: "user", Content: "Reply with exactly: pong"}},
    })
    if err != nil {
        panic(err)
    }
    fmt.Println(completion.Choices[0].Message.Content)
}
```

## Verify the result

| Place          | Expected result                                      |
| -------------- | ---------------------------------------------------- |
| Program output | `pong`                                               |
| JoyToken Logs  | Request reaches the OpenAI Chat Completions endpoint |
| JoyToken Usage | Tokens and credits are recorded                      |

## Common errors

| Error                    | Fix                                                                        |
| ------------------------ | -------------------------------------------------------------------------- |
| `401 Unauthorized`       | Check that `JOY_TOKEN_API_KEY` exists and is complete                      |
| `403 Forbidden`          | Check whether the API key policy allows `auto` or the target model         |
| `402 insufficient_quota` | Check wallet balance and key budget                                        |
| Timeout                  | Increase the SDK timeout or check connectivity to the selected environment |

## Next steps

* [Examples](/client-sdk/examples) �?streaming, Anthropic, model list, error handling
* [TypeScript SDK](/client-sdk/type-script-sdk/overview) · [Go SDK](/client-sdk/go-sdk/overview) �?client options and tool calling