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

# Migrate from OpenAI

> Connect your existing OpenAI SDK or framework to NoMask with a new base URL, API key, and model.

NoMask supports the OpenAI Chat Completions request and response format. Keep your existing SDK and message history, configure the NoMask connection, and choose a model from the [catalog](https://nomask.ai/models).

## Change your connection

| Setting | NoMask value |
| - | - |
| Base URL | `https://api.nomask.ai/v1` |
| API key | Your NoMask key from [API Keys](https://nomask.ai/api/keys) |
| Model | An exact model ID from the NoMask catalog |
| Text API | Chat Completions: `client.chat.completions.create(...)` |

Leave `/chat/completions` off the base URL; the SDK adds it. An OpenAI model name is not automatically mapped to a NoMask model.

Set `NOMASK_API_KEY` and `NOMASK_MODEL` in your server environment, then run one of these examples. Replace `your-model-id` with a current text model ID.

```bash theme={"system"}
export NOMASK_API_KEY="nmk_live_..."
export NOMASK_MODEL="your-model-id"
```

> [tab] Python
>
> Install the SDK with `pip install openai`.
>
> ```python theme={"system"}
> import os
> from openai import OpenAI
>
> client = OpenAI(
>     base_url="https://api.nomask.ai/v1",
>     api_key=os.environ["NOMASK_API_KEY"],
> )
>
> response = client.chat.completions.create(
>     model=os.environ["NOMASK_MODEL"],
>     messages=[{"role": "user", "content": "Explain a database index in one sentence."}],
> )
> print(response.choices[0].message.content)
> ```

> [tab] JavaScript
>
> Install the SDK with `npm install openai`. Save this example as `main.mjs` and run `node main.mjs`.
>
> ```javascript theme={"system"}
> import OpenAI from "openai";
>
> const client = new OpenAI({
>   baseURL: "https://api.nomask.ai/v1",
>   apiKey: process.env.NOMASK_API_KEY,
> });
>
> const response = await client.chat.completions.create({
>   model: process.env.NOMASK_MODEL,
>   messages: [{ role: "user", content: "Explain a database index in one sentence." }],
> });
> console.log(response.choices[0].message.content);
> ```

> [!NOTE]
>
> Choose **OpenAI Compatible** and **Chat Completions** when your tool offers multiple API modes. NoMask does not expose `/responses` or Anthropic's `/messages` endpoint. Tools that require those formats need an adapter; see [Codex](https://docs.nomask.ai/integration-codex.md) or [Claude Code](https://docs.nomask.ai/integration-claude-code.md).

## Connect a framework

Use the same environment variables as above. Select Chat Completions explicitly when a framework also supports Responses.

> [tab] Vercel AI SDK
>
> Install `ai` and `@ai-sdk/openai`.
>
> ```javascript theme={"system"}
> import { createOpenAI } from "@ai-sdk/openai";
> import { generateText } from "ai";
>
> const nomask = createOpenAI({
>   baseURL: "https://api.nomask.ai/v1",
>   apiKey: process.env.NOMASK_API_KEY,
> });
>
> const { text } = await generateText({
>   model: nomask.chat(process.env.NOMASK_MODEL),
>   prompt: "Explain a database index in one sentence.",
> });
> console.log(text);
> ```
>
> Use `nomask.chat(...)`; the default model factory uses the Responses API. See the [AI SDK OpenAI provider documentation](https://ai-sdk.dev/providers/ai-sdk-providers/openai).

> [tab] LangChain
>
> Install `langchain-openai`.
>
> ```python theme={"system"}
> import os
> from langchain_openai import ChatOpenAI
>
> model = ChatOpenAI(
>     model=os.environ["NOMASK_MODEL"],
>     base_url="https://api.nomask.ai/v1",
>     api_key=os.environ["NOMASK_API_KEY"],
>     use_responses_api=False,
> )
> print(model.invoke("Explain a database index in one sentence.").content)
> ```
>
> Use standard chat and function tools, within the selected model's capabilities. See the [LangChain ChatOpenAI documentation](https://docs.langchain.com/oss/python/integrations/chat/openai).

For another SDK or client, configure its custom base URL, Bearer key, model ID, and Chat Completions mode. Check which optional fields it sends against the supported parameters below.

## What carries over

| Capability | NoMask behavior |
| - | - |
| Messages | `system`, `user`, `assistant`, and `tool` roles |
| Responses | `chat.completion` objects with `choices`, `finish_reason`, and `usage` |
| Streaming | `chat.completion.chunk` events over SSE; see [Streaming](https://docs.nomask.ai/streaming.md) |
| Tool calls | `tools`, `tool_choice`, and `parallel_tool_calls` on models with function calling |
| Image input | Image content parts on [vision-capable models](https://docs.nomask.ai/vision.md) |
| Sampling | `temperature`, `top_p`, `frequency_penalty`, and `presence_penalty`, subject to model support |
| Output limits | `max_tokens` or `max_completion_tokens`; `stop` accepts one string or up to four strings |
| Errors | OpenAI-style `error` objects with `message`, `type`, `code`, and `param` |

Model capabilities and limits are available through `GET /models`. For all fields, see [Chat Completions](https://docs.nomask.ai/chat-completions.md). Video input uses NoMask's supported [video message format](https://docs.nomask.ai/video-inputs.md).

## Images

NoMask also provides `POST /images/generations` and `POST /images/edits`. Select an image model, request one image (`n: 1`), and use `response_format: "b64_json"`. Images are returned inline rather than as hosted URLs. Supported dimensions, formats, and reference-image counts depend on the model.

The [Image Generation reference](https://docs.nomask.ai/image-generation.md) covers generation, multipart edits, JSON references, and response decoding.

## Add NoMask options

Keep your own instructions in a `system` message. Use `nomask_system_prompt` to prepend NoMask's persona, and reasoning options to control supported models. With Python, put NoMask-specific fields in `extra_body`; with JavaScript, add them to the request body.

> [tab] Python
>
> ```python theme={"system"}
> response = client.chat.completions.create(
>     model=os.environ["NOMASK_MODEL"],
>     messages=[{"role": "user", "content": "Explain how binary search works."}],
>     extra_body={
>         "reasoning": {"enabled": True, "effort": "high"},
>         "nomask_system_prompt": True,
>     },
> )
> ```

> [tab] JavaScript
>
> ```javascript theme={"system"}
> const response = await client.chat.completions.create({
>   model: process.env.NOMASK_MODEL,
>   messages: [{ role: "user", content: "Explain how binary search works." }],
>   reasoning: { enabled: true, effort: "high" },
>   nomask_system_prompt: true,
> });
> ```

| Parameter | Purpose |
| - | - |
| `reasoning` | An object with `enabled` and `effort`; supported levels depend on the model. |
| `reasoning_effort` | Shorthand for effort: `none`, `minimal`, `low`, `medium`, `high`, `xhigh`, or `max`. `none` requests Off. |
| `nomask_system_prompt` | Enables NoMask's persona before your own messages; defaults to off. |

See [Reasoning](https://docs.nomask.ai/reasoning.md) for model-specific adjustments and [System Prompt](https://docs.nomask.ai/system-prompt.md) for persona behavior.

## Account for the differences

* **Choose a NoMask model ID.** IDs and capabilities come from the NoMask catalog. Unknown IDs return `404 model_not_found`.
* **Use a NoMask balance.** Paid requests draw from your prepaid USD balance. Completed responses add `nomask.cost_usd`; see [Billing & Funding](https://docs.nomask.ai/billing.md).
* **Read extensions when needed.** Responses can include `reasoning_content`, warnings, and the `nomask` metadata object. A framework may not preserve every extra field.
* **Keep tools in your application.** Function calls describe work for your code to execute. The developer API does not provide built-in web search or browsing tools.
* **Use supported endpoints.** Responses, legacy Completions, Embeddings, Audio, Files, Assistants, and Moderations APIs are not provided. Use Chat Completions for text and the documented image endpoints for images.
* **Send file text as text.** Extract document contents in your application; file uploads and file content parts are not supported by the chat endpoint.

## Unsupported request options

These options return `400 unsupported_parameter`, with the field identified in `error.param`:

| Option | How to adapt |
| - | - |
| `functions`, `function_call` | Use `tools` and `tool_choice`. |
| `logprobs`, `top_logprobs` | Remove probability-output options. |
| `audio`, `modalities`, `prediction` | Remove these unsupported chat options. |
| `n` other than `1` | Send one completion per request. |
| `response_format` with `json_object` or `json_schema` | Use text output; JSON mode and structured-output enforcement are not supported. |
| Web-search or browsing parameters | Run your own tools and send their results as messages. |

Start with the minimal SDK request, then add streaming, tools, or multimodal inputs supported by your selected model. [Errors](https://docs.nomask.ai/errors.md) explains failure codes; [Rate Limits](https://docs.nomask.ai/rate-limits.md) covers retry behavior.

> [card] [Chat Completions](https://docs.nomask.ai/chat-completions.md)
>
> Check request fields and the response format.

> [card] [Coding tools](https://docs.nomask.ai/integration-cline.md)
>
> Connect an OpenAI-compatible coding assistant.


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