SDKs and libraries

Build with the tools you already run. Meta Model API works with the OpenAI SDK and the Anthropic SDK — no custom client to learn. Point the OpenAI SDK at the Model API base URL for Responses and Chat Completions, or point the Anthropic SDK at Model API for the Messages format. Any OpenAI-compatible SDK, HTTP client, or framework — such as LangChain, LlamaIndex, or Vercel AI SDK — works with Model API too.

Supported features

Through the OpenAI SDK you can call:

Python

Install the package:

shell
pip install openai

Send a request:

Python (OpenAI SDK)
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["MODEL_API_KEY"],
base_url="https://api.meta.ai/v1",
)
response = client.responses.create(
model="muse-spark-1.3",
input="Explain mixture-of-experts in two sentences.",
)
print(response.output_text)

TypeScript

Install the package:

shell
npm install openai

Send a request:

TypeScript (OpenAI SDK)
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.MODEL_API_KEY,
baseURL: "https://api.meta.ai/v1",
});
const response = await client.responses.create({
model: "muse-spark-1.3",
input: "Explain mixture-of-experts in two sentences.",
});
console.log(response.output_text);

Anthropic SDK

Use the Anthropic SDK for Model API's Messages API. Set the base host to https://api.meta.ai — the SDK appends /v1/messages — and pass your Model API key as a bearer token:

Python (Anthropic SDK)
import os
from anthropic import Anthropic
client = Anthropic(
base_url="https://api.meta.ai",
auth_token=os.environ["MODEL_API_KEY"],
)
message = client.messages.create(
model="muse-spark-1.3",
max_tokens=1024,
messages=[{"role": "user", "content": "Explain mixture-of-experts in two sentences."}],
)
print(message.content[0].text)

See the Messages API guide for the full request and response shape.

Authentication

The OpenAI SDK looks for OPENAI_API_KEY by default, not MODEL_API_KEY. Pass your Model API key explicitly when you create the client:

Python (OpenAI SDK)
client = OpenAI(
api_key=os.environ["MODEL_API_KEY"],
base_url="https://api.meta.ai/v1",
)

See Authentication for details on creating and managing API keys.