provod.ai / docs
API

Migrate an OpenAI-compatible client

Change the base URL and API key in an existing OpenAI-compatible integration.

Last updated on

Run a complete SDK example

You can keep the official OpenAI SDK for methods covered by the provod.ai compatibility surface. You need Node.js, npm, curl, and jq. Start with one non-streaming Chat Completions request, meaning one complete JSON response rather than incremental output.

Install the SDK

Terminal
npm install openai

Set the key and choose a current model

Query text models that accept the max_tokens used by the example. The checks below require available == true and exclude image endpoint entries.

Terminal
set -euo pipefail

export PROVOD_API_KEY="sk_..."

if ! MODELS_JSON="$(
  curl --fail-with-body --silent --show-error "https://api.provod.ai/v1/models?output_modalities=text&supported_parameters=max_tokens" \
    -H "Authorization: Bearer $PROVOD_API_KEY"
)"; then
  printf '%s\n' "$MODELS_JSON" >&2
  exit 1
fi

if ! PROVOD_MODEL="$(
  jq -er '
    first(
      .data[]
      | select(
          .available == true
          and ((.architecture.output_modalities // []) | index("text"))
          and ((.supported_parameters // []) | index("max_tokens"))
          and ((.supported_endpoint_types // []) | all(. != "image-generation" and . != "image-edit"))
        )
      | .id
    )
  ' <<<"$MODELS_JSON"
)"; then
  printf 'No available text model with max_tokens found in /v1/models.\n' >&2
  exit 1
fi

export PROVOD_MODEL
printf '%s\n' "$PROVOD_MODEL"

Create the client and request

Save this as migrate.mjs:

migrate.mjs
import OpenAI from "openai";

const apiKey = process.env.PROVOD_API_KEY;
const model = process.env.PROVOD_MODEL;

if (!apiKey || !model) {
  throw new Error("Set PROVOD_API_KEY and PROVOD_MODEL");
}

const client = new OpenAI({
  apiKey,
  baseURL: "https://api.provod.ai/v1"
});

const completion = await client.chat.completions.create({
  model,
  messages: [{ role: "user", content: "Reply with ok" }],
  max_tokens: 64
});

console.log(completion.choices[0]?.message?.content);

Run it and read the output

Terminal
node migrate.mjs

A successful run prints the text from choices[0].message.content, for example:

Output
ok

An existing OpenAI-compatible client changes only its base URL and key.

Keep the SDK; point supported methods to provod.ai.

Move new configurations to provod.ai

Existing clients that still use api.promptra.ru can use it as a compatibility address during the migration. For every new or actively updated configuration, use https://api.provod.ai/v1. The compatibility address is a migration aid, not an indefinite availability promise.

Understand the compatibility boundary

Changing baseURL does not make every OpenAI endpoint available. The example works because client.chat.completions.create() maps to the published POST /v1/chat/completions contract. provod.ai also publishes model discovery and documented image endpoints, but it does not currently publish POST /v1/responses, embeddings, or audio transcription and translation endpoints.

Check the method used by your SDK or tool before migrating it. If it requires an unpublished endpoint and cannot switch to Chat Completions or Messages, changing the URL alone will not make it compatible.

Keep discovery in your setup

Refresh GET /v1/models instead of treating a model ID copied from this example as permanent. Use each model's current availability and supported_parameters when building optional request fields.

A public error code is the client-facing value in an API error, usually error.code. Record it with the HTTP status when diagnosing a migration; do not use private transport details.

Troubleshooting

On this page