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

# Create API Keys

> Create and manage enterprise developer API keys

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

## Create a Key

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

* **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 developer API key list](/_fern-files/_img/a2b0165444cc2c746ca8e8ee8cb46f2662a181d6f00afb3a52e626a963cfe256.webp)![Create enterprise developer API key](/_fern-files/_img/0c88124c98137ae101f4c73eb3b81ff932b62432b388df22307e8a33adc70f94.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/fab1118bafad1dc0f20ec22ca5d29f9747c4a618446554f0944ff347f2ab1f8f.webp)![Playground routing details](/_fern-files/_img/c0f3aa2600406c9cb19aa021f6eb08fcb43bf24143138f1c690a0a94e82a6430.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/6aacd7d5180d0e3ab714ad7995d3289df0808ee4251a66e3e1db3bd004b3d8ff.webp)![](/_fern-files/_img/c4209839003e1ee1e1a1c452a63bea86437f28bcb9601022ddc569acf9328741.webp)![](/_fern-files/_img/7d8deae0bfaa3b5bfd794f436a8e64f8465bc6f60333574b963828f3a8854596.webp)![](/_fern-files/_img/60aae78d017d6bd657aec653836a59f85058a55c7d7e3883f35b302de6c55585.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>