OpenAI Python SDK
Install the SDK:
python -m pip install openai
Set OPENAI_API_KEY and OPENAI_BASE_URL as shown in LLM SDKs. Then run this Python code:
from openai import OpenAI
client = OpenAI()
response = client.chat.completions.create(
model="claude-sonnet",
messages=[{"role": "user", "content": "In one sentence, explain what an AI model is."}],
)
print(response.choices[0].message.content)
The code prints the response of the model. To use a different model, change the model value.
Use the Responses API
response = client.responses.create(model="gpt-6-luna", input="Say hello.")
print(response.output_text)
Select a provider
To select the provider that serves the model, add a header when you create the client:
client = OpenAI(default_headers={"X-AmSC-MAG-Provider": "openai"})
or:
client = OpenAI(default_headers={"X-AmSC-MAG-Provider": "microsoft"})