APIrove

Home / API docs / OpenAI-compatible API

INTEGRATION GUIDE

OpenAI-compatible API: quick integration

Point your existing client's base URL at APIrove, and call the GPT or Grok models available to your account with a server-side API key.

Guide · AI API integration · About 5 min read

Before you start

  1. Sign in to the console and confirm your account balance, model access, and model ID.
  2. Create a dedicated API key and store it only on your application server.
  3. Confirm that the model you chose supports the Responses API or Chat Completions.

API base URL: https://apirove.com/v1

cURL: Responses API request example

The cURL request format has been verified in low-limit tests. The example below applies to models in your account that support the Responses format. Set environment variables in your terminal first so the key stays out of your code:

export APIROVE_API_KEY='YOUR_API_KEY'
export APIROVE_MODEL='YOUR_MODEL_ID'

curl https://apirove.com/v1/responses \
  -H "Authorization: Bearer $APIROVE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"'"$APIROVE_MODEL"'","input":"Hello!","max_output_tokens":16}'

Chat Completions request example

If the model details say it supports Chat Completions, you can use this endpoint:

curl https://apirove.com/v1/chat/completions \
  -H "Authorization: Bearer $APIROVE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"'"$APIROVE_MODEL"'","messages":[{"role":"user","content":"Hello!"}],"max_tokens":16}'

Receive streaming responses

A streaming response returns the result in chunks. The example below uses the Responses API; before using it, you still need to confirm that the selected model and your account support this endpoint:

curl -N https://apirove.com/v1/responses \
  -H "Authorization: Bearer $APIROVE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"'"$APIROVE_MODEL"'","input":"Explain what an API is in one sentence.","stream":true,"max_output_tokens":16}'

The terminal shows the event stream sent by the server. In an application, read the SSE events one at a time and stop after the completion event. Before retrying after a disconnect, check whether the previous request was already billed, so you do not submit it twice.

Python OpenAI SDK setup

Common OpenAI SDKs usually let you set a custom base URL. Put the key in an environment variable, then set the APIrove base URL in the SDK. This example uses the Responses API:

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["APIROVE_API_KEY"],
    base_url="https://apirove.com/v1",
)

response = client.responses.create(
    model=os.environ["APIROVE_MODEL"],
    input="Hello!",
    max_output_tokens=16,
)
print(response.output_text)

Different OpenAI SDK versions may support different endpoints. If the client or model does not support the Responses API, use the Chat Completions endpoint once you have confirmed it is compatible.

Common problems

  • 401: Confirm that the key is correct, has not been revoked, and is sent in Bearer format.
  • 403: Check account status, model access, and whether the model supports the endpoint you used.
  • 429: Lower the request rate and check your account quota or concurrency limit; do not retry rapidly right away.
  • 5xx: Record the request ID in the response (if any). Before retrying later, confirm whether the request completed and whether it generated usage.
  • Charges differ: go by the model prices and usage details shown in your signed-in account.
Keep API keys only in server-side environment variables or a secret manager. Do not put them in browser front-end code, public repositories, mobile app packages, or logs. For more advice, see the API key security guide.