MuseSpark
MuseSpark
Start here

Anthropic-compatible quickstart

Send a native Messages request with curl or an Anthropic SDK.

Enable llm_compat and llm:invoke, then set MUSESPARK_API_KEY. Replace the example model ID with one from the Anthropic catalog.

curl

curl --fail-with-body 'https://api.musespark.ai/proxy/anthropic/v1/messages' \
  -H "Authorization: Bearer $MUSESPARK_API_KEY" \
  -H 'anthropic-version: 2023-06-01' \
  -H 'Content-Type: application/json' \
  -d '{"model":"YOUR_AUTHORIZED_MODEL_ID","max_tokens":256,"messages":[{"role":"user","content":"Explain asynchronous APIs in one sentence."}]}'

The response contains a native content array, which can contain text and other block types.

Python SDK

Install anthropic in your application environment.

import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ["MUSESPARK_API_KEY"],
    base_url="https://api.musespark.ai/proxy/anthropic",
)
message = client.messages.create(
    model="YOUR_AUTHORIZED_MODEL_ID",
    max_tokens=256,
    messages=[{"role": "user", "content": "Explain asynchronous APIs in one sentence."}],
)
for block in message.content:
    if block.type == "text":
        print(block.text)

JavaScript SDK

Install @anthropic-ai/sdk in your server application.

import Anthropic from '@anthropic-ai/sdk';

const client = new Anthropic({
  apiKey: process.env.MUSESPARK_API_KEY,
  baseURL: 'https://api.musespark.ai/proxy/anthropic',
});
const message = await client.messages.create({
  model: 'YOUR_AUTHORIZED_MODEL_ID',
  max_tokens: 256,
  messages: [{ role: 'user', content: 'Explain asynchronous APIs in one sentence.' }],
});
for (const block of message.content) {
  if (block.type === 'text') console.log(block.text);
}

System instructions, tools, and multimodal blocks depend on model support. Read the Messages reference and the selected model's guide.

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