# OpenAI SDK

Source: https://staging-docs.aiand.com/sdks/openai/

The ai& Inference API is wire-compatible with OpenAI's. Use the official `openai` SDKs by overriding the base URL.

## Setup

<Tabs>
<TabItem label="Python">

```bash
pip install openai
```

```python
from openai import OpenAI

client = OpenAI(
    base_url="https://api.aiand.com/v1",
    api_key="sk-your-aiand-api-key",
)
```

</TabItem>
<TabItem label="Node.js">

```bash
npm install openai
```

```ts

const client = new OpenAI({
  baseURL: "https://api.aiand.com/v1",
  apiKey: "sk-your-aiand-api-key",
});
```

</TabItem>
</Tabs>

## Chat completion

```python
response = client.chat.completions.create(
    model="...",
    messages=[{"role": "user", "content": "Hello"}],
)
print(response.choices[0].message.content)
```

## Streaming

```python
stream = client.chat.completions.create(
    model="...",
    messages=[{"role": "user", "content": "Hello"}],
    stream=True,
    stream_options={"include_usage": True},
)
for chunk in stream:
    print(chunk.choices[0].delta.content or "", end="")
```

## Other surfaces

- `client.files.create(...)` — [Files](/api/files/)
- `client.models.list()` — [Models](/api/models/)

<Aside type="tip">
  For tool calling, structured outputs, vision, and parallel tool calls — see the [Capabilities](/capabilities/streaming/) section. Everything works as-is with the OpenAI SDK.
</Aside>
