Markdown ↗

OHGROK / Integration guide

Python

Use the OpenAI Python SDK with an explicit ohgrok base URL.

On this page

Install and configure

Run this example on your backend or local machine. Set OHGROK_API_KEY first. JavaScript uses Node.js and an ES module (.mjs).

Terminal
python -m pip install openai
export OHGROK_API_KEY='YOUR_API_KEY'

Request example

SDK examples cover text chat. Follow the dedicated endpoints for images and video.

Python
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["OHGROK_API_KEY"],
    base_url="https://api.ohgrok.com/v1",
    max_retries=0,
)
response = client.chat.completions.create(
    model="grok-4.5",
    messages=[{"role": "user", "content": "Hello, ohgrok!"}],
)
print(response.choices[0].message.content)

Read the result and handle failures

Read choices[0].message.content. Keep usage when present. SDK retries are disabled here so a beginner can inspect the first error before sending another request. Enable bounded retries only after reviewing the operation and billing behavior.