MuseSpark
MuseSpark
Start here

OpenAI-compatible quickstart

Connect with curl, the OpenAI Python SDK, or server-side JavaScript.

Enable product llm_compat and scope llm:invoke. Set MUSESPARK_API_KEY in your server environment. Replace YOUR_AUTHORIZED_MODEL_ID with an ID from the OpenAI model catalog.

curl

curl --fail-with-body 'https://api.musespark.ai/proxy/openai/v1/chat/completions' \
  -H "Authorization: Bearer $MUSESPARK_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"model":"YOUR_AUTHORIZED_MODEL_ID","messages":[{"role":"user","content":"Explain asynchronous APIs in one sentence."}],"stream":false}'

The assistant message is in choices[].message.

Python SDK

Install the openai package in your application environment.

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["MUSESPARK_API_KEY"],
    base_url="https://api.musespark.ai/proxy/openai/v1",
)
response = client.chat.completions.create(
    model="YOUR_AUTHORIZED_MODEL_ID",
    messages=[{"role": "user", "content": "Explain asynchronous APIs in one sentence."}],
    stream=False,
)
print(response.choices[0].message.content)

JavaScript

const response = await fetch('https://api.musespark.ai/proxy/openai/v1/chat/completions', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.MUSESPARK_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    model: 'YOUR_AUTHORIZED_MODEL_ID',
    messages: [{ role: 'user', content: 'Explain asynchronous APIs in one sentence.' }],
    stream: false,
  }),
  signal: AbortSignal.timeout(120_000),
});
if (!response.ok) throw new Error(`HTTP ${response.status}: ${await response.text()}`);
const result = await response.json();
console.log(result.choices[0].message.content);

Responses

For a model supporting Responses, use POST /proxy/openai/v1/responses with model and input.

response = client.responses.create(
    model="YOUR_AUTHORIZED_MODEL_ID",
    input="Explain asynchronous APIs in one sentence.",
)
print(response.output_text)

See Chat Completions and Responses for their separate request and response contracts.

If the request fails

  • For HTTP 401, verify the API key and credential header.
  • For HTTP 403, check the llm_compat product, invocation scope, and access to the selected model.
  • If optional fields are rejected, check the model's supported capabilities and the operation reference.
  • If a call times out after submission, treat its execution as uncertain. The task API's idempotency mechanism does not apply to compatibility calls; replaying the request can start another paid execution.

Next steps