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

# Create an API key

> Creates a new API key associated with one or more workspaces.
The response includes the key token which is only shown once upon creation.



## OpenAPI

````yaml /spec/ai-keys.yaml post /v1/keys
openapi: 3.0.1
info:
  title: AI - API Keys
  description: >-
    Manage API keys for AI workspace access. API keys are used to authenticate
    inference

    requests (chat completions, embeddings, image generation).


    Parameters:

    - `teamID`: To access services in a team (query param or `x-teamid` header)


    Authentication: JWT Bearer token sent via the `Authorization` header.
  termsOfService: '#'
  contact:
    email: info@liara.ir
  version: 1.0.0
servers:
  - url: https://ai.liara.ir
security:
  - jwt: []
tags:
  - name: API Keys
    description: Manage API keys for AI inference
externalDocs:
  description: Find out more about Liara AI
  url: https://liara.ir
paths:
  /v1/keys:
    post:
      tags:
        - API Keys
      summary: Create an API key
      description: >-
        Creates a new API key associated with one or more workspaces.

        The response includes the key token which is only shown once upon
        creation.
      operationId: createKey
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateKeyRequest'
      responses:
        '201':
          description: API key created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateKeyResponse'
        '400':
          description: Bad request - at least one workspace must be selected
          content: {}
        '401':
          description: Missing authentication
          content: {}
        '409':
          description: Conflict - key name already exists
          content: {}
components:
  schemas:
    CreateKeyRequest:
      type: object
      required:
        - name
        - workspaces
      properties:
        name:
          type: string
          minLength: 3
          maxLength: 15
          pattern: ^[A-Za-z0-9._~| -]+$
          description: Unique name for the API key
        workspaces:
          type: array
          items:
            type: string
          minItems: 1
          description: Array of workspace names to associate with this key
    CreateKeyResponse:
      type: object
      properties:
        name:
          type: string
        enabled:
          type: boolean
        workspaces:
          type: array
          items:
            type: object
            properties:
              _id:
                type: string
              name:
                type: string
        key:
          type: string
          description: The JWT token for this API key (only shown once)
        createdBy:
          type: object
          properties:
            fullname:
              type: string
        _id:
          type: string
  securitySchemes:
    jwt:
      type: apiKey
      description: 'Enter the token with the `Bearer: ` prefix, e.g. "Bearer abcde12345"'
      name: Authorization
      in: header

````