> ## 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 (OpenAI format)

> Creates a chat completion in OpenAI-compatible format.

This endpoint is designed to accept messages and parameters in the OpenAI format, meaning that you can use it with existing OpenAI-compatible clients and libraries.

In contrast to our standard chat completion endpoint, this one runs independently of amber functionalities, and is intended for users who want to use OpenAI-compatible tools and libraries without relying on amber-specific features.

For reference, see the [OpenAI Create chat completion documentation](https://developers.openai.com/api/reference/resources/chat/subresources/completions/methods/create).


<RequestExample>
  ```python Default theme={null}
  from openai import OpenAI
  client = OpenAI(
      base_url="https://customerDomain.ambersearch.de/api/beta/openai/v1",
      api_key="ambrs-exampletoken"
  )

  completion = client.chat.completions.create(
    model="azure/gpt-5.4",
    messages=[
      {"role": "developer", "content": "You are a helpful assistant."},
      {"role": "user", "content": "Hello!"}
    ]
  )

  print(completion.choices[0].message)
  ```

  ```python Image input theme={null}
  from openai import OpenAI

  client = OpenAI(
      base_url="https://customerDomain.ambersearch.de/api/beta/openai/v1",
      api_key="ambrs-exampletoken"
  )

  response = client.chat.completions.create(
      model="azure/gpt-5.4",
      messages=[
          {
              "role": "user",
              "content": [
                  {"type": "text", "text": "What's in this image?"},
                  {
                      "type": "image_url",
                      "image_url": {
                          "url": "https://ambersearch.de/uploads/amber_Team_73637a5596.jpg",
                      }
                  },
              ],
          }
      ],
      max_tokens=300,
  )

  print(response.choices[0])
  ```

  ```python Streaming theme={null}
  from openai import OpenAI
  client = OpenAI(
      base_url="https://customerDomain.ambersearch.de/api/beta/openai/v1",
      api_key="ambrs-exampletoken"
  )

  completion = client.chat.completions.create(
    model="azure/gpt-5.4",
    messages=[
      {"role": "developer", "content": "You are a helpful assistant."},
      {"role": "user", "content": "Hello!"}
    ],
    stream=True
  )

  for chunk in completion:
    print(chunk.choices[0].delta)
  ```

  ```python Functions theme={null}
  from openai import OpenAI
  client = OpenAI(
      base_url="https://customerDomain.ambersearch.de/api/beta/openai/v1",
      api_key="ambrs-exampletoken"
  )

  tools = [
    {
      "type": "function",
      "function": {
        "name": "get_current_weather",
        "description": "Get the current weather in a given location",
        "parameters": {
          "type": "object",
          "properties": {
            "location": {
              "type": "string",
              "description": "The city and state, e.g. Aachen, North Rhine-Westphalia",
            },
            "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]},
          },
          "required": ["location"],
        },
      }
    }
  ]
  messages = [{"role": "user", "content": "What's the weather like in Aachen today?"}]
  completion = client.chat.completions.create(
    model="azure/gpt-5.4",
    messages=messages,
    tools=tools,
    tool_choice="auto"
  )

  print(completion)
  ```
</RequestExample>

<ResponseExample>
  ```python Default theme={null}
  ChatCompletionMessage(
      content='Hello! How can I help you today?',
      refusal=None,
      role='assistant',
      annotations=None,
      audio=None,
      function_call=None,
      tool_calls=None
  )
  ```

  ```python Image input theme={null}
  Choice(
      finish_reason='stop',
      index=0,
      logprobs=None,
      message=ChatCompletionMessage(
          content='This image shows a large group of people posing outdoors on a sloped stone walkway or steps, surrounded by trees. Most of them are wearing matching blue sweatshirts, suggesting they may be part of a team, company, or group event. Many are raising their hands or making cheerful poses, so it looks like a casual group photo.\n\nOn the left side, there’s part of a building and a sign that appears to say “SUMIANI HOTEL & BEACH.” The setting looks sunny and wooded, possibly at a hotel or retreat location.',
          refusal=None,
          role='assistant',
          annotations=None,
          audio=None,
          function_call=None,
          tool_calls=None
      )
  )
  ```

  ```python Streaming theme={null}
  ChoiceDelta(content='Hello', function_call=None, refusal=None, role=None, tool_calls=None)
  ChoiceDelta(content='!', function_call=None, refusal=None, role=None, tool_calls=None)
  ChoiceDelta(content=' How', function_call=None, refusal=None, role=None, tool_calls=None)
  ChoiceDelta(content=' can', function_call=None, refusal=None, role=None, tool_calls=None)
  ChoiceDelta(content=' I', function_call=None, refusal=None, role=None, tool_calls=None)
  ChoiceDelta(content=' help', function_call=None, refusal=None, role=None, tool_calls=None)
  ChoiceDelta(content=' you', function_call=None, refusal=None, role=None, tool_calls=None)
  ChoiceDelta(content=' today', function_call=None, refusal=None, role=None, tool_calls=None)
  ChoiceDelta(content='?', function_call=None, refusal=None, role=None, tool_calls=None)
  ChoiceDelta(content=None, function_call=None, refusal=None, role=None, tool_calls=None)
  ```

  ```python Functions theme={null}
  ChatCompletion(
      id='chatcmpl-DufEoQk1y55a5G8XzKBnAe63ceFdA',
      choices=[
          Choice(
              finish_reason='tool_calls',
              index=0,
              logprobs=None,
              message=ChatCompletionMessage(
                  content=None,
                  refusal=None,
                  role='assistant',
                  annotations=None,
                  audio=None,
                  function_call=None,
                  tool_calls=[
                      ChatCompletionMessageFunctionToolCall(
                          id='call_Tug3jwD1JpmzTapCFFWmYw7i',
                          function=Function(
                              arguments='{"location":"Aachen, North Rhine-Westphalia","unit":"celsius"}', name='get_current_weather'
                          ),
                          type='function',
                          index=0
                      )
                  ]
              )
          )
      ],
      created=1782397258,
      model='gpt-5.4-2026-03-05',
      object='chat.completion',
      service_tier='default',
      system_fingerprint='',
      usage=CompletionUsage(
          completion_tokens=31,
          prompt_tokens=164,
          total_tokens=195,
          completion_tokens_details=CompletionTokensDetails(
              accepted_prediction_tokens=None,
              audio_tokens=None,
              reasoning_tokens=None,
              rejected_prediction_tokens=None
          ),
          prompt_tokens_details=PromptTokensDetails(
              audio_tokens=None,
              cached_tokens=0
          )
      )
  )
  ```
</ResponseExample>
