MandAPI
English ▾
Get started

Move an OpenAI-compatible chat integration to MandAPI

Change the chat connection boundary while preserving the application's existing messages, response handling and interface.

Use this recipe with your coding assistant

Read the prompt
Migrate this project's verified OpenAI-compatible Chat Completions paths to MandAPI with the smallest coherent change. First identify its language, package manager, framework, client initialization, chat callers, streaming consumers, tool calls and JSON expectations. Set the base URL to https://api.mandapi.com/v1, use the secret MANDAPI_API_KEY and select a real model through MANDAPI_MODEL_ID. Never print or commit a key, invent model IDs, or assume another provider's aliases work. Keep existing UI protocols, persisted messages, tools, retries and public APIs. Do not migrate embeddings, images, audio, Responses or provider-specific APIs without verifying compatibility; list them as separate decisions. Update the configuration example and README. Run the project's relevant local checks. A real request requires my usable key and authorization; otherwise report that no live test ran. Summarize changed files, checks, retained paths and rollback settings.
TXT

Choose the boundary to change

Start with an application that already sends OpenAI-compatible Chat Completions. Keep its UI, message storage, tool execution, timeouts and streaming protocol. The basic connection settings are the endpoint, API key and model ID. A provider change does not automatically make every provider-specific feature compatible.

This recipe covers chat requests. Handle embeddings, images, audio, assistants and Responses API calls separately when you have verified their endpoint, model and request shape.

Record the current behavior

Before editing, identify the package manager, client initialization, environment variables and model selection. Find all callers, including background summaries and classification jobs. Record whether each call streams, uses tools or expects structured JSON. Keep one example input and expected response behavior without personal data or secrets.

Create a separate MandAPI key in your dashboard. Select a real model ID from the catalog and your account's available model list. Do not carry over another platform's model alias.

Make the smallest connection change

A Python connection can look like this:

python
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["MANDAPI_API_KEY"],
    base_url="https://api.mandapi.com/v1",
)
model_id = os.environ["MANDAPI_MODEL_ID"]

Pass model_id to the existing Chat Completions call. Update your secret settings and configuration example, but keep real keys out of the repository. In another framework, use its documented custom OpenAI-compatible provider option rather than replacing the entire application.

Verify before switching traffic

Run existing local checks first. Compare a complete response and a streamed response with the original UI contract. Test any tool and JSON path actually used by the application. If a model does not support a feature, leave that integration on its existing route until you choose a suitable replacement.

When you authorize a small live check, confirm content and usage in your account. Keep the previous provider configuration available for rollback. Do not copy balances or assume the two providers use the same billing fields.

Copy instructions for your coding assistant

Use the accompanying prompt at your project's root. It asks the assistant to inspect before editing and to identify unsupported paths explicitly. A successful result is a narrow chat migration with checks and setup instructions, not a rewrite of unrelated features.

References

Topics inspired by public documentation; instructions and examples adapted for MandAPI.