Lewati ke konten

Playbook··2 menit baca

Moving From a Direct Provider SDK to One Gateway, Without a Rewrite

Change the base URL, swap in an sk-pc key, name models as provider/model. A practical checklist for moving an existing app onto Pecutin in an afternoon.

Tim Pecutin

Read in English

If your app already calls a model provider through its SDK, moving to a gateway should not mean rewriting it. Here is the checklist we recommend, in the order we recommend it.

1. Create a key for the service you are moving

In the console, create a key just for this service, for example "chatbot-staging". Give it a quota that matches what you expect it to spend. Starting with one key per service makes the before-and-after comparison clean.

2. Change the base URL and the key

With an OpenAI-compatible SDK, the change is usually two values:

import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.pecutin.co/v1",
    api_key=os.environ["PECUTIN_API_KEY"],  # sk-pc-...
)

Your request code, streaming, and error handling stay as they are.

3. Name the model with its provider

Models are addressed as provider/model. The full list of providers and models, with prices, is in the console. Because the provider is part of the name, trying the same prompt on another provider is a one-string change, and a routing rule can make that change for you without touching code at all.

4. Move one service, then compare

Send real traffic from one service first. Compare cost per request in the ledger and response time in the logs against what you had before. When the numbers look right, move the next service.

5. Keep the old path for a while

Do not revoke the old provider key on day one. Keep it until the new path has served real traffic through a normal week, including a busy hour. Then revoke it, so there is only one place your app's AI spend can come from.

Pertanyaan yang sering diajukan

Do I have to change my prompts?

No. The prompt and the response format are the same; only where the request is sent changes.

Can I keep using my existing provider account?

Yes. Connect it as BYOK or BYOA, and requests can still run on it through Pecutin, with usage shown apart from billed cost.

Berhenti mengurus akun satu per satu. Mulai dari satu kunci.