SDKs and libraries
Build with the clients you already run. Meta Model API doesn't need a client of its own: use the OpenAI SDK for the Responses API and Chat Completions API, the Anthropic SDK for the Messages API, or any OpenAI-compatible client, such as LangChain, LlamaIndex, the Vercel AI SDK, or LiteLLM. Set the client's base URL, pass your Model API key, and keep the rest of your code.
Supported features
Through the OpenAI SDK you can call:
- Responses API (
client.responses.create()) - Chat completions (
client.chat.completions.create()) - Search grounding (via Responses API)
- Image understanding (vision)
- Video and audio understanding (Responses API and Chat Completions)
- Structured output (
response_format) - Tool calling
- File uploads (
client.files.create()) - Streaming
- Temperature and sampling parameters
- Model selection
Python
Install the package:
pip install openaiSend a request:
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:
npm install openaiSend a request:
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 the Model API Messages API. Set base_url to https://api.meta.ai (the SDK appends /v1/messages), and pass your Model API key as auth_token, which the SDK sends as a bearer token.
A response's content starts with a redacted_thinking block that carries the model's encrypted reasoning, so read the text blocks instead of indexing content[0]:
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("".join(block.text for block in message.content if block.type == "text"))See the Messages API guide for the full request and response shape.
OpenAI-compatible clients
Any client or framework that speaks the OpenAI API and accepts a custom base URL works with Model API, including LangChain, LlamaIndex, the Vercel AI SDK, and LiteLLM. Most ask for three values: the base URL https://api.meta.ai/v1, your Model API key, and a model ID such as muse-spark-1.3.
LiteLLM reaches Model API through its OpenAI provider, so prefix the model ID with openai/:
pip install litellmimport os
import litellm
response = litellm.completion(
model="openai/muse-spark-1.3",
api_base="https://api.meta.ai/v1",
api_key=os.environ["MODEL_API_KEY"],
messages=[{"role": "user", "content": "Explain mixture-of-experts in two sentences."}],
)
print(response.choices[0].message.content)Segment Anything Model client libraries
Segment Anything Model 3.1 (SAM 3.1) returns its boxes and masks as a token grammar in the Responses output text. The Meta-SAM client libraries decode it for you. @meta-sam/parser (TypeScript) and meta_sam_parser (Python) turn the stream into typed segmentation snapshots and decode masks. The optional @meta-sam/graphics, @meta-sam/video, and @meta-sam/react packages draw overlays and play segmented video.
Install them and parse your first stream with the Segment Anything Model client libraries guide.
Authentication
None of these clients reads MODEL_API_KEY on its own. The OpenAI SDK looks for OPENAI_API_KEY and the Anthropic SDK looks for ANTHROPIC_API_KEY, so pass your Model API key explicitly when you create the client:
import os
from openai import OpenAI
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.
Mirrored from dev.meta.ai/docs/sdks (synced Oct 30, 2026). Text and examples © Meta. Live demos run on Muse Muse's key.