> For the complete documentation index, see [llms.txt](https://docs.robinmesh.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.robinmesh.com/integrations/openai-compatible.md).

# OpenAI-Compatible Usage

RobinMesh speaks the OpenAI wire protocol: identical request bodies in, identical response bodies out. Code written against the OpenAI SDK, in any language, needs exactly two changes to run on RobinMesh: a new base URL and a new API key.

***

## Compatibility matrix

| Feature                                 | Compatible                         |
| --------------------------------------- | ---------------------------------- |
| `POST /v1/chat/completions`             | Yes, streaming included            |
| `GET /v1/models`                        | Yes, plus extra `robinmesh` fields |
| Streaming (SSE)                         | Yes                                |
| `max_tokens`, `temperature`, `top_p`    | Yes                                |
| `stop` sequences                        | Yes                                |
| `frequency_penalty`, `presence_penalty` | Yes                                |
| System and multi-turn messages          | Yes                                |
| Tool / function calling                 | Planned for Phase 2                |
| Embeddings (`/v1/embeddings`)           | Planned for Phase 2                |
| Image inputs (`vision`)                 | Planned for Phase 2                |
| Assistants API                          | No                                 |
| Fine-tuning API                         | No                                 |

***

## Python (OpenAI SDK)

```python
from openai import OpenAI

client = OpenAI(
    base_url="https://api.robinmesh.com/v1",
    api_key="rmesh_live_your_key_here"
)

# Non-streaming
response = client.chat.completions.create(
    model="qwen3-8b",
    messages=[
        {"role": "system", "content": "You are a concise assistant."},
        {"role": "user", "content": "What is llama.cpp?"}
    ]
)
print(response.choices[0].message.content)

# Streaming
stream = client.chat.completions.create(
    model="llama-3.3-70b",
    messages=[{"role": "user", "content": "Explain zero-knowledge proofs."}],
    stream=True
)

for chunk in stream:
    print(chunk.choices[0].delta.content or "", end="", flush=True)
```

***

## TypeScript / Node.js (OpenAI SDK)

```typescript
import OpenAI from "openai"

const client = new OpenAI({
    baseURL: "https://api.robinmesh.com/v1",
    apiKey: "rmesh_live_your_key_here"
})

// Non-streaming
const response = await client.chat.completions.create({
    model: "qwen3-8b",
    messages: [
        { role: "system", content: "You are a concise assistant." },
        { role: "user", content: "What is llama.cpp?" }
    ]
})
console.log(response.choices[0].message.content)

// Streaming
const stream = await client.chat.completions.create({
    model: "llama-3.3-70b",
    messages: [{ role: "user", content: "Explain zero-knowledge proofs." }],
    stream: true
})

for await (const chunk of stream) {
    process.stdout.write(chunk.choices[0]?.delta?.content ?? "")
}
```

***

## Keeping the key out of your code

API keys belong in environment variables, not in source files.

```bash
export ROBINMESH_API_KEY="rmesh_live_your_key_here"
```

```python
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.robinmesh.com/v1",
    api_key=os.environ["ROBINMESH_API_KEY"]
)
```

```typescript
const client = new OpenAI({
    baseURL: "https://api.robinmesh.com/v1",
    apiKey: process.env.ROBINMESH_API_KEY!
})
```

***

## Getting at the on-chain receipt data

Each RobinMesh response carries extra headers describing the job's on-chain settlement, and the OpenAI SDK quietly drops them. To read the transaction hashes, make the HTTP call yourself and inspect the raw response.

```python
import httpx

response = httpx.post(
    "https://api.robinmesh.com/v1/chat/completions",
    headers={"Authorization": f"Bearer {api_key}"},
    json={
        "model": "qwen3-8b",
        "messages": [{"role": "user", "content": "Hello"}]
    }
)

job_id = response.headers.get("x-robinmesh-job-id")
settlement_tx = response.headers.get("x-robinmesh-settlement-tx")
print(f"Job: {job_id}")
print(f"Settlement tx: https://robinhoodchain.blockscout.com/tx/{settlement_tx}")
```

For typed receipts, structured streaming, and wallet-native auth, reach for the \[JavaScript SDK]\(

) or follow the \[Python usage guide]\().

***

## Picking a model

Model IDs on RobinMesh are its own; none of OpenAI's names carry over. `GET /v1/models` returns the live catalog. Rough equivalences:

| OpenAI model    | Comparable RobinMesh model | Notes                                        |
| --------------- | -------------------------- | -------------------------------------------- |
| `gpt-4o`        | `llama-3.3-70b`            | Solid all-around reasoning                   |
| `gpt-4o-mini`   | `qwen3-8b`                 | Quick, inexpensive, handles most workloads   |
| `gpt-3.5-turbo` | `mistral-7b`               | Cheapest and fastest option                  |
| none            | `deepseek-r1`              | Built for extended reasoning, math, and code |

***

## Where behavior diverges from OpenAI

**Prepaid credits, not invoices.** There is no monthly bill. You load a credit balance up front, and API calls draw it down; an empty balance means no calls.

**Settlement headers on every response.** Look for `x-robinmesh-job-id` and `x-robinmesh-tx-hash`, which describe the job's on-chain settlement. OpenAI responses carry nothing comparable.

**Capacity pricing instead of rate limits.** No policy team hands out quotas. When workers for your model run dry you receive a `503` carrying a `retry_after` value, and that is the extent of it: well-behaved clients see no queues and no throttling.

**Deprecation by governance.** Model IDs stay stable. Retiring one takes a RobinMesh community vote to remove it from the recommended list, announced ahead of time; the ID keeps working until that deprecation lands rather than expiring after a two-week warning window.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.robinmesh.com/integrations/openai-compatible.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
