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:
- 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) - File uploads (
client.files.create())
Python
Install the package:
shellpip install openai
Send a request:
Python (OpenAI SDK)import osfrom openai import OpenAIclient = 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:
shellnpm 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 osfrom anthropic import Anthropicclient = 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.