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)
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://amber.de/uploads/amber_Team_73637a5596.jpg",
}
},
],
}
],
max_tokens=300,
)
print(response.choices[0])
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:
if chunk.choices:
print(chunk.choices[0].delta)
if chunk.usage:
print(chunk.usage)
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)
ChatCompletionMessage(
content='Hello! How can I help you today?',
refusal=None,
role='assistant',
annotations=None,
audio=None,
function_call=None,
tool_calls=None
)
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
)
)
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)
CompletionUsage(completion_tokens=10, prompt_tokens=18, total_tokens=28, completion_tokens_details=None, prompt_tokens_details=None)
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
)
)
)
OpenAI-like Endpoints
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.
POST
/
api
/
beta
/
openai
/
v1
/
chat
/
completions
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)
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://amber.de/uploads/amber_Team_73637a5596.jpg",
}
},
],
}
],
max_tokens=300,
)
print(response.choices[0])
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:
if chunk.choices:
print(chunk.choices[0].delta)
if chunk.usage:
print(chunk.usage)
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)
ChatCompletionMessage(
content='Hello! How can I help you today?',
refusal=None,
role='assistant',
annotations=None,
audio=None,
function_call=None,
tool_calls=None
)
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
)
)
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)
CompletionUsage(completion_tokens=10, prompt_tokens=18, total_tokens=28, completion_tokens_details=None, prompt_tokens_details=None)
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
)
)
)
When streaming, amber always enables
stream_options.include_usage. The last chunk of the stream therefore contains the token usage. Depending on the model provider, chunks can have an empty choices list, so check that choices is not empty before accessing choices[0]. The stream ends with data: [DONE].{"error": {"message": ..., "type": ..., "param": null, "code": ...}}):
400if the request body is not a JSON object.403(access_denied) if AI access is not enabled for your account.404(model_not_found) if the model does not exist or is not available to you.429(insufficient_quota) if your API budget is exhausted.500(typeserver_error,codenull) if the request could not be processed.
402 is returned as 429. With "stream": true the response status is always 200: a provider error that occurs before generation starts is returned as a plain JSON body instead of server-sent events, and errors that occur during generation end the stream early.
Authentication and plan errors are checked before the request reaches this endpoint and use the standard amber format {"detail": "..."} instead:
401if theAuthorizationheader is missing (Not authenticated), or if the token is invalid, expired or not an API key / OAuth2 access token (for exampleToken is invalidorToken expired).403if your tenant is on a free trial or its license plan has expired.
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)
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://amber.de/uploads/amber_Team_73637a5596.jpg",
}
},
],
}
],
max_tokens=300,
)
print(response.choices[0])
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:
if chunk.choices:
print(chunk.choices[0].delta)
if chunk.usage:
print(chunk.usage)
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)
ChatCompletionMessage(
content='Hello! How can I help you today?',
refusal=None,
role='assistant',
annotations=None,
audio=None,
function_call=None,
tool_calls=None
)
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
)
)
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)
CompletionUsage(completion_tokens=10, prompt_tokens=18, total_tokens=28, completion_tokens_details=None, prompt_tokens_details=None)
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
)
)
)