Skip to main content

Quick Start - Generative AI

Overview

Welcome to the documentation for the Connected AI Platform (CAIP) Large Language Model (LLM) API. This API provides a unified interface to interact with various LLM model providers, including AWS Bedrock, Azure OpenAI and Alibaba Cloud.

Quickstart

Take your first steps with the CAIP LLM API.

Base URL

We have provided both prod and non-prod URLs, but for use cases we recommend using only the prod URL. Using the non-prod URL is not meaningful, as it is intended for internal CAIP testing purposes.

RegionURL
RoWhttps://llm.api.caip.bmw.cloud
Chinahttps://llm.api.caip.bmwchina.cloud

Authentication

API keys can be obtained through the Self-Service Portal or by raising a Service Request of type 'Request API Key'.

The API key must be provided in the Authorization header of each request.

RoW (new stack):

Authorization: Bearer <your_api_key>

China (legacy stack):

Authorization: <your_api_key>
RoW Breaking Changes
  • The model must be specified in the JSON body (passing it via header is no longer supported).
  • The Authorization header must use the Bearer prefix (RoW).
  • Only UUID-format API keys are accepted (RoW).

Curl Example

RoW (Recommended — OpenAI Compatible Format):

curl -X 'POST' \
'https://llm.api.caip.bmw.cloud/v1/chat/completions' \
-H 'accept: application/json' \
-H 'Authorization: Bearer {Your_apikey}' \
-H 'Content-Type: application/json' \
-d '{
"model": "gpt-4o",
"messages": [
{
"role": "system",
"content": "You are a mathematician"
},
{
"role": "user",
"content": "What is 1+1?"
}
]
}'

China:

curl -X 'POST' \
'https://llm.api.caip.bmwchina.cloud/v1/chat/completions' \
-H 'accept: application/json' \
-H 'Authorization: {Your_apikey}' \
-H 'Content-Type: application/json' \
-d '{
"model": "qwen-plus",
"messages": [
{
"role": "system",
"content": "You are a mathematician"
},
{
"role": "user",
"content": "What is 1+1?"
}
]
}'

OpenAI SDK Support

The LLMAPI is fully compatible with the OpenAI Python SDK which has been adopted by the vast majority of the GenAI industry.

OpenAI Client Setup — RoW (new stack)

The RoW endpoint is fully OpenAI-compatible. Pass your API key directly:

from openai import OpenAI

client = OpenAI(
base_url="https://llm.api.caip.bmw.cloud/v1",
api_key="{Your_apikey}"
)

OpenAI Client Setup — China (legacy stack)

The China endpoint still uses the legacy authentication pattern with the API key passed as an additional header:

from openai import OpenAI

client = OpenAI(
base_url="https://llm.api.caip.bmwchina.cloud/v1",
api_key="",
default_headers={
"Authorization": "{Your_apikey}",
}
)

Chat Completion Usage

After correct initialization of the OpenAI client, the chat completion endpoint can be used by specifying the model directly:

RoW:

completion = client.chat.completions.create(
model="gpt-4o",
messages=[
{
"role": "user",
"content": "Write a one-sentence bedtime story about a unicorn."
}
],
)
print(completion.choices[0].message.content)

China:

completion = client.chat.completions.create(
model="qwen-plus",
messages=[
{
"role": "user",
"content": "Write a one-sentence bedtime story about a unicorn."
}
],
)
print(completion.choices[0].message.content)

Additionally, the optional streaming parameter can be set to ensure fast model responses e.g. for building a ChatBot.

Next Steps

For comprehensive documentation including supported models, advanced features, and detailed API specifications, please refer to:

-> Complete LLM API Documentation

This detailed guide covers:

  • Full list of supported models by region
  • Advanced authentication methods
  • Streaming responses and model-specific features
  • Architecture overview and API key management
  • Complete code examples and best practices