amberSearch and webSearch, to enhance your application’s capabilities.
The base URL for the API is:
Supported Endpoints
- GET /models
- GET /models/
- POST /chat/completions
- GET /credits
DELETE /models/{model}, GET /chat/completions, GET, POST and DELETE /chat/completions/{completion_id} and GET /chat/completions/{completion_id}/messages) exist, but they are not functional and return 405 Endpoint not supported. if you try to use them.
In addition to the endpoints above, which run through the amber AI pipeline, we provide a plain OpenAI-compatible API at
https://customerDomain.ambersearch.de/api/beta/openai/v1 with GET /models, POST /chat/completions and GET /credits. It forwards your request to the model as is, without amber tools, agents or files. See Create chat completion (OpenAI format) and List models (OpenAI format).Authentication
Authorization for the endpoints is the same as other Endpoints. You need to provide an API key (or an OAuth2 client access token) in theAuthorization header of your request, prefixed with Bearer . Regular amber web app session tokens are not accepted by these endpoints.
403.
Models
Model endpoints are for getting the model identifiers, which are needed to create chat completions. Each model has a unique identifier, and you can retrieve the list of available models or details about a specific model using the following endpoints:GET /modelsto list all available models.GET /models/{model}to get details about a specific model.
404.
Each model has a pricing object with its price in credits per 1 million tokens: input, output and cached_input (null if the model has no cache price). These are the base prices; for some models, prompts above 200k tokens cost more. pricing is null if no price is known for a model.
Usage and credits
Every chat completion reports what it used in itsusage object: the tokens and the credits the request costs. A single request can make several model calls (for example when the model uses amberSearch), and usage covers all of them.
credits is computed from the token counts and the model prices.
To see how many credits you have left, call GET /credits:
remaining: the credits you can still spend through the API in the current period, i.e. the lower of your company’s remaining API credits and what is left of your personal limit. Once it reaches0, chat completions return429(insufficient_quota).used: the credits you used this calendar month (API and premium models in amber).personal_limit: your monthly credits limit set by your admin, ornullif you have none.api_access: whether your company allows API usage. Iffalse,remainingis0.period_start/period_end: the current credits period (UTC), ornullif your company has no credits.
Chat Completions
The chat completions endpoint is used to generate responses based on a given set of messages. For getting chat completions, you can specify the model you want to use, the messages that form the conversation, and various parameters to control the generation process. It mirrors the same flow that would happen if similar inputs (messages, tools, model) were provided via the amber frontend. Let’s take a look at the endpoints:Create Chat Completion
The endpoint for creating chat completions is:- messages:
list(required) - model:
str(required) - stream:
bool(defaultfalse) - temperature:
float(default1.0) - metadata:
dict(default{}) - tools:
list(default[])
Messages
We follow the same structure as OpenAI for the messages parameter, which is a list of message objects. Each message object should have arole and content. The roles can be one of the following:
systemuserassistant
developer) are ignored, so use system for instructions. The content can be a string or a list of text parts ({"type": "text", "text": "..."}), which are joined into one text. Image parts are not supported on this endpoint and are rejected with 422. At least one user or assistant message is required, otherwise the request fails with 400 (see Errors for streaming requests).
Response
Without streaming, the endpoint returns achat.completion object. The answer is in choices[0].message.content. If the answer cites sources (e.g. from amberSearch or webSearch), the citations are written into the text as ([title](url)) and listed as url_citation entries in choices[0].message.annotations. The usage object contains the tokens and credits of the request (see Usage and credits).
With "stream": true, the endpoint returns server-sent events. Each event is a data: line containing a chat.completion.chunk object; the stream may also contain SSE comment lines (: ping - ...) as keep-alives, which SSE clients ignore. The first chunk’s delta contains "role": "assistant", and the following chunks contain the next piece of text in delta.content (plus delta.annotations if that piece contains citations). In a streamed annotation, start_index and end_index refer to the content of the same chunk, not to the whole message. The stream ends with a chunk whose delta is empty and whose finish_reason is "stop". Only this last chunk has a usage object with the tokens and credits of the whole request. No data: [DONE] message is sent; the stream is simply closed.
Errors
400ifwebSearchis requested but web search is not available for your account, ifweb_search_modeis invalid, or if nouser/assistantmessage is given.403if AI access is not enabled for your account, or if your tenant is on a free trial or its license plan has expired.404if the model or the agent does not exist or is not available to you.422if the request body is malformed (e.g. a missing required field or an image content part).429with the error codeinsufficient_quotaif your API budget is exhausted.500ifmetadata.agent_idis not a valid UUID, or if the request could not be processed.
Tools
We officially support two tools at the moment:amberSearch and webSearch. If no tool is passed, the model cannot perform any search in external or internal data sources. It can still e.g. give an answer based on its own knowledge only, or process an uploaded file (if it is passed as described below).
To specify which tool should be used, simply pass it in the request body as follows:
amber_search and web_search are accepted as aliases. Tools with unknown names are ignored. The names of other amber tools (deepResearch, outlook, imageGeneration, videoGeneration and canvas) are also accepted and passed to the pipeline, but they are not officially supported via the API and their behaviour may change. If you request webSearch but web search is not enabled for your account, the request fails with 400 Web search tool is not available.
Agents
To create chat completions with an agent, you need to specify the agent ID in the metadata of the request body as follows:- The agent’s model is used instead of the
modelfrom the request. Themodelfrom the request is still required and must be one of your available models, otherwise the request fails with404. - The agent’s tools replace the
toolsfrom the request. - The agent’s instructions are added in front of your
systemmessages. - The agent’s files are available in addition to the files you pass in
metadata.files.
404. The agent_id must be a valid UUID; any other value currently results in 500.
Files
To attach files to the chat completion request, you can use thefiles parameter in the metadata of the request body as follows:
files parameter should be a list of file IDs that you have previously received when uploading files to amber via the /api/beta/files/upload endpoint. Instead of plain IDs, you can also pass objects with an id (or file_id) field. File IDs that cannot be found or that you don’t have access to are skipped.
Web search mode
When thewebSearch tool is enabled, you can control which search engine it uses for this request via the web_search_mode parameter in the metadata of the request body as follows:
web_search_mode parameter accepts one of the following values:
search- a standard Brave web search that also crawls the resulting pages for their full content.context- Brave’s LLM Context API, which returns content optimized for grounding an LLM response without crawling individual pages.perplexity- the Perplexity Search API.staan_context- the staan.ai search API, returning relevance-scored passages of the resulting pages.staan_full- the staan.ai search API, returning the whole resulting pages as markdown.
web_search_mode is omitted (or set to an empty string), the tenant’s configured default is used, falling back to search if no default is set. Values are case-insensitive. Any other value is rejected with 400, even if the webSearch tool is not included in tools. Apart from this validation, the parameter has no effect if the webSearch tool is not included.
Language
To specify which language your messages are in, you can use thelanguage parameter in the metadata of the request body as follows:
language parameter is de (German). If you don’t specify it, the system will assume that the messages are in German. If you want to use English, you need to explicitly set the language parameter to en.
This is mostly relevant for very short user inputs, where the model has to ‘guess’ the language it should respond in.