# 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](https://dev.meta.ai/docs/protocols/responses) and [Chat Completions](https://dev.meta.ai/docs/protocols/chat-completions), or point the Anthropic SDK at Model API for the [Messages](https://dev.meta.ai/docs/protocols/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](https://dev.meta.ai/docs/protocols/responses) (`client.responses.create()`)
- [Chat completions](https://dev.meta.ai/docs/protocols/chat-completions) (`client.chat.completions.create()`)
- [Search grounding](https://dev.meta.ai/docs/search-grounding) (via Responses API)
- [Image understanding](https://dev.meta.ai/docs/image-understanding) (vision)
- [Video and audio understanding](https://dev.meta.ai/docs/video-understanding) (Responses API and Chat Completions)
- [Structured output](https://dev.meta.ai/docs/structured-output) (`response_format`)
- [Function calling / tool use](https://dev.meta.ai/docs/tool-calling)
- [File uploads](https://dev.meta.ai/docs/file-handling) (`client.files.create()`)
- [Streaming](https://dev.meta.ai/docs/protocols/chat-completions#streaming)
- [Temperature and sampling parameters](https://dev.meta.ai/docs/protocols/chat-completions#parameters)
- [Model selection](https://dev.meta.ai/docs/protocols/chat-completions#parameters)

## Python

Install the package:

```shell
pip install openai
```

Send a request:

**Python (OpenAI SDK)**

```python
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)**

```typescript
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](https://dev.meta.ai/docs/protocols/messages). 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)**

```python
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](https://dev.meta.ai/docs/protocols/messages) 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)**

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

See [Authentication](https://dev.meta.ai/docs/authentication) for details on creating and managing API keys.
