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

# OpenAI-compatible API migration guide for Python, Node.js, and curl

> Use an OpenAI-compatible API by changing the base URL and API key. Includes migration steps for Python, Node.js, streaming, and tool calling checks.

# OpenAI-compatible API migration guide for Python, Node.js, and curl

An **OpenAI-compatible API** lets your application keep the same request style while sending traffic through a different base URL. This is the fastest way to test another AI provider, AI gateway, or model marketplace without rewriting your application.

<img src="https://mintcdn.com/rockapi/Y2PJHTzmky-wG67e/images/blog/openai-compatible-migration.svg?fit=max&auto=format&n=Y2PJHTzmky-wG67e&q=85&s=bc1871eb1890b7d04c2c0231c6543da3" alt="OpenAI-compatible migration diagram showing developers keeping the OpenAI SDK and changing the base URL and API key" width="1200" height="630" data-path="images/blog/openai-compatible-migration.svg" />

Rock API exposes an OpenAI-compatible API at:

```txt theme={null}
https://rockapi.ai/v1
```

## Python example

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

client = OpenAI(
    base_url="https://rockapi.ai/v1",
    api_key="YOUR_ROCK_API_KEY",
)

response = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[{"role": "user", "content": "Hello from Rock API"}],
)

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

## Node.js example

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

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

const response = await client.chat.completions.create({
  model: "gpt-4o-mini",
  messages: [{ role: "user", content: "Hello from Rock API" }],
});

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

## Migration checklist

| Step                | What to verify                                            |
| ------------------- | --------------------------------------------------------- |
| Change the base URL | Point the SDK to `https://rockapi.ai/v1`.                 |
| Replace the API key | Use a Rock API key instead of a provider key.             |
| Confirm model names | Use model IDs enabled in your Rock API account.           |
| Test streaming      | Set `stream: true` and confirm SSE handling.              |
| Check tool calling  | Test the exact tool or function call paths your app uses. |
| Review billing      | Confirm token usage appears in your dashboard.            |

## FAQ

### Is an OpenAI-compatible API the same as OpenAI?

No. It means the API follows the OpenAI request and response shape closely enough for OpenAI-style SDKs and clients. The upstream model may be OpenAI, Anthropic, Google, or another supported provider.

### Can I use Claude with the OpenAI SDK?

Yes, when the gateway exposes Claude models through an OpenAI-compatible interface. Your application keeps the OpenAI-style client and selects the Claude model name supported by the gateway.

### Can I use Gemini with the OpenAI API format?

Yes, if the gateway provides Gemini models through an OpenAI-compatible endpoint. Test model-specific behavior before production, especially tool calls and streaming edge cases.

## Next step

For a broader model selection guide, read [AI model API comparison](/blog/buyers/ai-model-api-comparison).
