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

# Create API Keys

> Create and manage enterprise API keys

After creating a protection policy, open the **API Keys** menu. This page is used to create and manage API keys.

## Create a Key

![Create enterprise API key](/_fern-files/_img/d45401b9649e29a55da83e4fb7bce9e5fe70285fee0ad1e31c3b8386d5b906d8.webp)

Click **Create New Key** in the top-right corner to open the creation dialog, then fill in the following as needed:

![Create enterprise API key dialog](/_fern-files/_img/9cfef331aea7b6e4622d1d0c33431907833cdaceb4013ca2e665e89f6264ec9d.webp)

* **Key Name**
* **Expiration Time**: e.g., never expire, 30 days, 90 days, or a custom time
* **Protection Policy**: policies already created under the **Protection Policies** menu are automatically pulled into the dropdown

> **Note**
>
> Each user can have at most 3 active keys at the same time.

## Key List

Filter by parameters or status, and open the row menu «⋮» to manage a key.

Displayed fields: **Key Name, Policy, Level, Usage Quota, Expiration Time, Actions**.

Clicking **Actions** opens a dropdown with "Details" and "Revoke":

* **Details**: view the key's identity information, ID, creation time, key prefix, policy configuration, and more.
* **Revoke**: invalidate the current key; a revoked key can no longer be used to call the API.

![Enterprise API key list](/_fern-files/_img/d45401b9649e29a55da83e4fb7bce9e5fe70285fee0ad1e31c3b8386d5b906d8.webp)

## Playground for Online Testing

The Playground is a built-in online testing tool that lets you chat with models directly without writing any code, ideal for quickly verifying whether a key works.

* **Left Panel**: Verify the API Key; review the selected policy's tier, product, industry pack, IP whitelist, quota, and model blacklist; configure temperature, maximum output tokens, and streaming.
* **Conversation Area**: Enter prompts, upload media, toggle configuration or inspector, and send.
* **Overview Panel**: Request status, request ID, key, policy, tier, model, cost, tokens, and latency details.
* **Routing Panel**: User settings, tier recommendation and scoring, selected model, hit probability, tags, and candidate models.

![Playground overview](/_fern-files/_img/b8d9915f9883b0623e01cc53e4d32a735163f6da6a9a42fc14477152b470bd15.webp)![Playground routing details](/_fern-files/_img/e7bd9393cf2d0732aa7a35a01098bd0eec664c4da5da4bc3e17385b4b7e8f0aa.webp)

### Playground Operations

**API Key Verification**: Before using the Playground, the entered key must be verified as valid. When a key is created successfully for the first time and you are redirected from API management, no input is required and the system verifies it automatically. After entering a key, click "Verify API Key"; the verification result is shown above the input box.

![Verify API key](/_fern-files/_img/76f4ae82773232eb2643841eadede372f5a4af89b805dd89e8693866fe4dc24b.webp)

**Generation Parameters - Temperature**: Controls randomness. Lower values are more stable, higher values are more divergent. Defaults to 0.7, applies to the Playground only.

![Generation parameters - temperature](/_fern-files/_img/3b06746f9d4af67dd369f8bba15d3d131b102ae60f5d14f85ed520a6cf71223c.webp)

**Max Output Tokens**: Limits the maximum length of the model's reply for this request. If exceeded, the model cannot output a result. Currently defaults to 4096, applies to the Playground only.

**Streaming Response**: When enabled, content is returned as it is generated, which is better suited for long replies and real-time preview; when disabled, the system waits for the complete response and returns it all at once. Currently enabled by default, applies to the Playground only.

![](/_fern-files/_img/3531ab9d434b97e173b8c0f2de7c222d9f8fb1db530ed9101e35419a90febb29.webp)![](/_fern-files/_img/3531ab9d434b97e173b8c0f2de7c222d9f8fb1db530ed9101e35419a90febb29.webp)![](/_fern-files/_img/cfc0a0908d6a1abb1e3ae0b129f7c61525dd309ff4041f55c6d5908d01a14342.webp)![](/_fern-files/_img/9332dd27e17f8fba0557356891450b02d39aa19745953e1597e5553ee3d8e28a.webp)![](/_fern-files/_img/6a96c6553c414847805cd2dd66bc2e43f6d8b6b1d8bde442d3a2b921e4ab9e2e.webp)![](/_fern-files/_img/d280310aad82b767aac56f1190031e08610ce8a25ef130ddd6916666036c5a36.webp)![](/_fern-files/_img/b9b8de5ff3b312d6ae5dfbb7e4d085286e38c418e5496c14a885be53f3af98f9.webp)![](/_fern-files/_img/e2f63a9f30d2d9f08630bdeb2e3d9ae1aaa1546eba6005bee76437a17f5033da.webp)![](/_fern-files/_img/9a90e746b661508ed045496fba3a1d2af04bf9bc63c536c4f368301eaad5af20.webp)

## API Call Examples

### Configure the Client

Fill the copied address into your client or code as the `base_url`, then use it together with your key to start making calls.

### Code Examples

TypeScript (OpenAI SDK):

```typescript
import { JoyTokenClient } from "@joytoken/client-sdk-ts";

const joytoken = new JoyTokenClient({
  apiKey,
  openAIBaseUrl: process.env.JOY_TOKEN_OPENAI_BASE_URL,
  timeoutMs: 60_000,
});
```

**Non-streaming:**

```typescript
const completion = await joytoken.chat.completions.create({
  model: "auto",
  messages: [{ role: "user", content: "Reply with exactly: pong" }],
});
console.log(completion.choices[0]?.message?.content);
```

**Streaming:**

```typescript
for await (const chunk of joytoken.chat.completions.stream({
  model: "auto",
  messages: [{ role: "user", content: "Write one short paragraph." }],
})) {
  process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}
```

**Claude native format:**

```bash
curl -sS -X POST "$JOY_TOKEN_ANTHROPIC_BASE_URL/messages" \
  -H "x-api-key: $JOY_TOKEN_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "auto",
    "messages": [
      { "role": "user", "content": "Reply with exactly: pong" }
    ],
    "temperature": 0.7,
    "max_tokens": 1024,
    "stream": false
  }'
```

### Supported API Endpoints

<table>
  <thead>
    <tr>
      <th>
        Endpoint
      </th>

      <th>
        Method & Path
      </th>

      <th>
        Description
      </th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        Chat Completions
      </td>

      <td>
        `POST /openai/v1/chat/completions`
      </td>

      <td>
        Chat generation with streaming support
      </td>
    </tr>

    <tr>
      <td>
        Responses
      </td>

      <td>
        `POST /openai/v1/responses`
      </td>

      <td>
        Generation in OpenAI Responses format
      </td>
    </tr>

    <tr>
      <td>
        Image Generations
      </td>

      <td>
        `POST /openai/v1/images/generations`
      </td>

      <td>
        Text-to-image generation
      </td>
    </tr>

    <tr>
      <td>
        Anthropic Messages
      </td>

      <td>
        `POST /anthropic/v1/messages`
      </td>

      <td>
        Generation in Anthropic Messages format
      </td>
    </tr>

    <tr>
      <td>
        List Models
      </td>

      <td>
        `GET /api/v1/models`
      </td>

      <td>
        Query the model catalog
      </td>
    </tr>

    <tr>
      <td>
        Model Filter Metadata
      </td>

      <td>
        `GET /api/v1/models/meta`
      </td>

      <td>
        Query model filter options
      </td>
    </tr>

    <tr>
      <td>
        Pricing
      </td>

      <td>
        `GET /api/v1/pricing`
      </td>

      <td>
        Query tier exchange rates
      </td>
    </tr>
  </tbody>
</table>