> ## Documentation Index
> Fetch the complete documentation index at: https://docs.runbridge.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Use RunBridge AI with OpenAI SDKs

> Configure the OpenAI Python and Node.js SDKs for RunBridge AI by setting the RunBridge AI API key and base URL.

Use the OpenAI SDK with RunBridge AI by changing two client settings: the API key and the base URL. Keep your existing OpenAI-compatible request code, then replace the model ID with an available RunBridge AI model ID.

## Install the SDK

The following command installs the OpenAI Python SDK:

```bash theme={null}
pip install openai
```

The following command installs the OpenAI Node.js SDK:

```bash theme={null}
npm install openai
```

## Python client

The following Python example creates a RunBridge AI client and sends a chat request:

```python theme={null}
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["RUNBRIDGE_API_KEY"],
    base_url="https://api.runbridge.ai/v1",
)

completion = client.chat.completions.create(
    model="your-model-id",
    messages=[
        {
            "role": "user",
            "content": "Answer in one short sentence: What is RunBridge AI?",
        }
    ],
)

print(completion.choices[0].message.content)
```

The response object contains the assistant message:

```json theme={null}
{
  "choices": [
    {
      "message": {
        "role": "assistant",
        "content": "RunBridge AI provides API access to models from multiple providers."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 16,
    "completion_tokens": 12,
    "total_tokens": 28
  }
}
```

## Node.js client

The following Node.js example uses `baseURL` with the OpenAI SDK:

```javascript theme={null}
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.RUNBRIDGE_API_KEY,
  baseURL: "https://api.runbridge.ai/v1",
});

const completion = await client.chat.completions.create({
  model: "your-model-id",
  messages: [
    {
      role: "user",
      content: "Answer in one short sentence: What is RunBridge AI?",
    },
  ],
});

console.log(completion.choices[0].message.content);
```

The response shape is the same OpenAI-compatible chat completion shape:

```json theme={null}
{
  "id": "chatcmpl_example",
  "object": "chat.completion",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "RunBridge AI provides API access to models from multiple providers."
      }
    }
  ]
}
```

## Common errors

| Error | Fix |
| - | - |
| `401` | Confirm that `RUNBRIDGE_API_KEY` is set and that the request uses `Bearer` auth. |
| SDK still calls OpenAI | Set `base_url` in Python or `baseURL` in Node.js. |
| Invalid model ID | Choose a model ID from the [Models page](/overview/models). |
| Missing `/v1` | Use `https://api.runbridge.ai/v1` for OpenAI-compatible SDKs. |

## Related links

* [RunBridge AI quickstart](/overview/quick-start)
* [Chat Completions](/api/text/chat)
* [Responses](/api/text/responses)
* [Models page](/overview/models)
* [Model directory](https://runbridge.ai/models/)
* [Pricing](https://runbridge.ai/pricing/)
* [OpenAI Python SDK](https://github.com/openai/openai-python)
* [OpenAI Node.js SDK](https://github.com/openai/openai-node)

<script type="application/ld+json">
  {`
    {
    "@context": "https://schema.org",
    "@graph": [
      {
        "@type": "TechArticle",
        "@id": "https://runbridge.mintlify.site/guides/use-runbridge-with-openai-sdk",
        "headline": "How do I use RunBridge AI with the OpenAI SDK?",
        "description": "Use RunBridge AI with the OpenAI Python and Node.js SDKs by setting the RunBridge AI API key and base URL.",
        "url": "https://runbridge.mintlify.site/guides/use-runbridge-with-openai-sdk",
        "author": {
          "@type": "Organization",
          "name": "RunBridge AI"
        },
        "publisher": {
          "@type": "Organization",
          "name": "RunBridge AI",
          "url": "https://runbridge.ai"
        }
      },
      {
        "@type": "BreadcrumbList",
        "itemListElement": [
          {
            "@type": "ListItem",
            "position": 1,
            "name": "RunBridge AI Docs",
            "item": "https://runbridge.mintlify.site/"
          },
          {
            "@type": "ListItem",
            "position": 2,
            "name": "Guides",
            "item": "https://runbridge.mintlify.site/guides/use-runbridge-with-openai-sdk"
          },
          {
            "@type": "ListItem",
            "position": 3,
            "name": "How do I use RunBridge AI with the OpenAI SDK?",
            "item": "https://runbridge.mintlify.site/guides/use-runbridge-with-openai-sdk"
          }
        ]
      }
    ]
    }
    `}
</script>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.