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

# Create chat completion

> Create a chat completion based on the provided messages and parameters.

This endpoint generates responses using the specified model and conversation history. You can also utilize tools and agents to enhance the response generation.


<RequestExample>
  ```python Default theme={null}
  import requests

  response = requests.request(
      "POST",
      "https://customerDomain.ambersearch.de/api/beta/amberai/chat/completions",
      headers={
          "Authorization": "Bearer ambrs-exampletoken"
      },
      json={
          "model": "azure/gpt-5.4",
          "temperature": 0.7,
          "stream": False,
          "tools": [],
          "messages": [
              {"role": "system", "content": "You are a helpful assistant."},
              {
                  "role": "user",
                  "content": "What would be the best activity to do in summer in Paris?",
              },
          ],
      },
  )
  ```

  ```python Streaming theme={null}
  import requests

  response = requests.request(
      "POST",
      "https://customerDomain.ambersearch.de/api/beta/amberai/chat/completions",
      headers={
          "Authorization": "Bearer ambrs-exampletoken"
      },
      json={
          "model": "azure/gpt-5.4",
          "temperature": 0.7,
          "stream": True,
          "tools": [],
          "messages": [
              {
                  "role": "system",
                  "content": "You are a helpful assistant."
              },
              {
                  "role": "user",
                  "content": "What is the capital of France?"
              }
          ]
      }
  )
  ```

  ```python Tools theme={null}
  import requests

  response = requests.request(
      "POST",
      "https://customerDomain.ambersearch.de/api/beta/amberai/chat/completions",
      headers={
          "Authorization": "Bearer ambrs-exampletoken"
      },
      json={
          "model": "azure/gpt-5.4",
          "temperature": 0.7,
          "stream": False,
          "tools": [
              {
                  "function": {
                      "name": "amberSearch"
                  }
              }
          ],
          "messages": [
              {
                  "role": "system",
                  "content": "You are a helpful assistant."
              },
              {
                  "role": "user",
                  "content": "What are the credentials for the postman development environment?"
              }
          ]
      }
  )
  ```

  ```python Web search mode theme={null}
  import requests

  response = requests.request(
      "POST",
      "https://customerDomain.ambersearch.de/api/beta/amberai/chat/completions",
      headers={
          "Authorization": "Bearer ambrs-exampletoken"
      },
      json={
          "model": "azure/gpt-5.4",
          "temperature": 0.7,
          "stream": False,
          "tools": [
              {
                  "function": {
                      "name": "webSearch"
                  }
              }
          ],
          "metadata": {
              "web_search_mode": "perplexity"
          },
          "messages": [
              {
                  "role": "system",
                  "content": "You are a helpful assistant."
              },
              {
                  "role": "user",
                  "content": "What are the latest developments in AI?"
              }
          ]
      }
  )
  ```

  ```python Agents theme={null}
  import requests

  response = requests.request(
      "POST",
      "https://customerDomain.ambersearch.de/api/beta/amberai/chat/completions",
      headers={
          "Authorization": "Bearer ambrs-exampletoken"
      },
      json={
          "model": "azure/gpt-5.4",
          "temperature": 0.7,
          "stream": False,
          "tools": [],
          "metadata": {
              "agent_id": "9676b2b0-9fdd-40b1-8a0a-0debe64b29ac"
          },
          "messages": [
              {
                  "role": "system",
                  "content": "You are a helpful assistant."
              },
              {
                  "role": "user",
                  "content": "How does web search in amberise work?"
              }
          ]
      }
  )
  ```

  ```python Files theme={null}
  import requests

  response = requests.request(
      "POST",
      "https://customerDomain.ambersearch.de/api/beta/amberai/chat/completions",
      headers={
          "Authorization": "Bearer ambrs-exampletoken"
      },
      json={
          "model": "azure/gpt-5.4",
          "temperature": 0.7,
          "stream": False,
          "metadata": {
              "files": ["01234567-89ab-cdef-0123-456789abcdef"]
          },
          "messages": [
              {
                  "role": "system",
                  "content": "Use the uploaded files to answer user's questions."
              },
              {
                  "role": "user",
                  "content": "How does web search in amberise work?"
              }
          ]
      }
  )
  ```
</RequestExample>


## OpenAPI

````yaml post /api/beta/amberai/chat/completions
openapi: 3.1.0
info:
  title: amber
  version: v0.1.46
servers:
  - url: https://{customerDomain}.ambersearch.de
    variables:
      customerDomain:
        default: customerDomain
security: []
paths:
  /api/beta/amberai/chat/completions:
    post:
      tags:
        - openai
      summary: Create Chat Completion
      description: Create chat completion
      operationId: create_chat_completion_api_beta_amberai_chat_completions_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateChatCompletionRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                anyOf:
                  - $ref: '#/components/schemas/ChatCompletion'
                  - type: string
                title: >-
                  Response Create Chat Completion Api Beta Amberai Chat
                  Completions Post
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - Bearer: []
components:
  schemas:
    CreateChatCompletionRequest:
      properties:
        messages:
          items:
            anyOf:
              - $ref: '#/components/schemas/ChatCompletionRequestSystemMessage'
              - $ref: '#/components/schemas/ChatCompletionRequestUserMessage'
              - $ref: '#/components/schemas/ChatCompletionRequestAssistantMessage'
          type: array
          title: Messages
        model:
          type: string
          title: Model
        stream:
          type: boolean
          title: Stream
          default: false
        temperature:
          type: number
          title: Temperature
          default: 1
        metadata:
          additionalProperties: true
          type: object
          title: Metadata
        tools:
          items:
            $ref: '#/components/schemas/Tool'
          type: array
          title: Tools
      type: object
      required:
        - messages
        - model
      title: CreateChatCompletionRequest
    ChatCompletion:
      properties:
        id:
          type: string
          title: Id
        object:
          type: string
          title: Object
          default: chat.completion
        created:
          type: integer
          title: Created
        model:
          type: string
          title: Model
        choices:
          items: {}
          type: array
          title: Choices
        usage:
          additionalProperties: true
          type: object
          title: Usage
        service_tier:
          type: string
          title: Service Tier
          default: default
        system_fingerprint:
          type: string
          title: System Fingerprint
          default: default
      type: object
      required:
        - id
        - created
        - model
        - choices
        - usage
      title: ChatCompletion
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ChatCompletionRequestSystemMessage:
      properties:
        content:
          anyOf:
            - type: string
            - items:
                $ref: '#/components/schemas/TextContent'
              type: array
          title: Content
        role:
          type: string
          title: Role
          default: system
        name:
          anyOf:
            - type: string
            - type: 'null'
          title: Name
      type: object
      required:
        - content
      title: ChatCompletionRequestSystemMessage
    ChatCompletionRequestUserMessage:
      properties:
        content:
          anyOf:
            - type: string
            - items:
                $ref: '#/components/schemas/TextContent'
              type: array
          title: Content
        role:
          type: string
          title: Role
          default: user
        name:
          anyOf:
            - type: string
            - type: 'null'
          title: Name
      type: object
      required:
        - content
      title: ChatCompletionRequestUserMessage
    ChatCompletionRequestAssistantMessage:
      properties:
        role:
          type: string
          title: Role
          default: assistant
        content:
          anyOf:
            - type: string
            - type: 'null'
          title: Content
        name:
          anyOf:
            - type: string
            - type: 'null'
          title: Name
        refusal:
          anyOf:
            - type: string
            - type: 'null'
          title: Refusal
      type: object
      title: ChatCompletionRequestAssistantMessage
    Tool:
      properties:
        function:
          $ref: '#/components/schemas/Function'
        type:
          type: string
          title: Type
          default: function
      type: object
      required:
        - function
      title: Tool
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    TextContent:
      properties:
        type:
          type: string
          title: Type
          default: text
        text:
          type: string
          title: Text
      type: object
      required:
        - text
      title: TextContent
    Function:
      properties:
        name:
          type: string
          title: Name
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
        parameters:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Parameters
      type: object
      required:
        - name
      title: Function
  securitySchemes:
    Bearer:
      type: http
      scheme: bearer

````