MARA Cloud provides an OpenAI-compatible API, making it easy to migrate existing OpenAI integrations with minimal changes.
Switching from OpenAI
Here is a standard OpenAI example:
python
from openai import OpenAI
client = OpenAI()
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)To switch to MARA Cloud:
- Set the
base_urlto the MARA Cloud endpoint:https://bczfskny6zqw.poweredby.snova.ai/v1 - Set your API key using the
MARA_API_KEYenvironment variable. Generate your key by following the API Keys and URLs page. - Specify the model you want to use (for example,
MiniMax-M2.5). See the Model Catalog for all available models.
That's it. No other changes are required.
Full example using MARA Cloud
python
import os
from openai import OpenAI
client = OpenAI(
base_url="https://bczfskny6zqw.poweredby.snova.ai/v1",
api_key=os.environ.get("MARA_API_KEY"),
)
completion = client.chat.completions.create(
model="MiniMax-M2.5",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Write a one-sentence bedtime story about a unicorn."},
],
)
print(completion.choices[0].message.content)