মূল অংশে যান

বাংলাদেশে ওপেনএআই-সামঞ্জস্যপূর্ণ এপিআই ব্যবহার

বেস ইউআরএল ও কী বদলে আপনার বিদ্যমান ওপেনএআই এসডিকে কোড TICON AI-এ চালান, টাকায় পরিশোধ করুন এবং সাধারণ ত্রুটি সামলান।

লেখক: [[PLACEHOLDER: author name]] · · পড়তে 6 মিনিট

এই পাতার লেখা ইংরেজিতে। বাংলা ও কোরিয়ান শিরোনাম ও সারাংশ মেশিন-অনূদিত খসড়া, মানুষের পর্যালোচনা বাকি।

If your code already talks to the OpenAI API, you can usually point it at TICON AI by changing two settings: the base URL and the API key. This guide shows the minimal steps, working examples, and the errors you are most likely to meet. You pay in Bangladeshi taka from a prepaid wallet.

During staging every model is a mock that returns placeholder text, and prices are samples. The request and response shapes below are real; the model output is not. [[PLACEHOLDER: update when real upstream providers are connected]]

What you need

  1. An account and an organization (sign-up takes an email address and a password).
  2. Money in the wallet. Top-ups are paid through EPS, a payment gateway in Bangladesh. Which payment methods are offered depends on EPS and on your country; this guide does not promise any particular method. [[PLACEHOLDER: list supported payment methods once confirmed]]
  3. An API key. Create one in the dashboard. The full key is shown once, starts with sk-aip-, and cannot be displayed again, so copy it into a secret store straight away.

Base URL and authentication

The OpenAI-compatible API lives under https://api.ticonai.com/v1. Send the key as a bearer token in the Authorization header. The same key also works with the Anthropic-style endpoint, where it can be sent as x-api-key.

  • POST /v1/chat/completions for OpenAI-style chat requests;
  • POST /v1/messages for Anthropic-style requests;
  • GET /v1/models to list the models your key may use.

Your first request

First list the models, then use one of the returned ids. Do not copy a model name from another provider; use the ids this endpoint returns.

export API_KEY="paste-your-key-here"

curl https://api.ticonai.com/v1/models \
  -H "Authorization: Bearer $API_KEY"

curl https://api.ticonai.com/v1/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "<a model id from /v1/models>",
    "messages": [{"role": "user", "content": "Say hello in Bangla."}],
    "max_tokens": 100
  }'

Using the official SDKs

With the OpenAI Python SDK, set base_url and api_key and keep the rest of your code unchanged:

import os
from openai import OpenAI

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

reply = client.chat.completions.create(
    model="<a model id from /v1/models>",
    messages=[{"role": "user", "content": "Say hello in Bangla."}],
    max_tokens=100,
)
print(reply.choices[0].message.content)

The same in Node.js:

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.ticonai.com/v1",
  apiKey: process.env.API_KEY,
});

const reply = await client.chat.completions.create({
  model: "<a model id from /v1/models>",
  messages: [{ role: "user", content: "Say hello in Bangla." }],
  max_tokens: 100,
});
console.log(reply.choices[0].message.content);

For the Anthropic style, call /v1/messages. max_tokens is required there, and an anthropic-version header such as 2023-06-01 is accepted:

curl https://api.ticonai.com/v1/messages \
  -H "x-api-key: $API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "<a model id from /v1/models>",
    "max_tokens": 100,
    "messages": [{"role": "user", "content": "Say hello in Bangla."}]
  }'

Streaming

Both endpoints accept stream: true and answer with server-sent events. For OpenAI-style streams, add stream_options: {"include_usage": true} if you want the final usage figures in the stream. If you close the connection early you are billed for the output already produced, as described in the post on prepaid billing and holds.

Errors you may see

Errors use the OpenAI-style body { "error": { "message", "type", "code", "param" } }, and every response carries an x-request-id header. Quote it when you contact support.

  • 401 invalid_api_key: the key is missing, unknown, revoked or expired.
  • 402 insufficient_balance: the available wallet amount does not cover the hold. Nothing was sent upstream and nothing was charged. Top up or lower max_tokens.
  • 403: the key is not allowed to use that model or call from that IP address, or the organization is suspended.
  • 404 model_not_found: the model id does not exist or is not active.
  • 429 rate_limited: slow down and retry after the number of seconds in the retry-after header.
  • 502 upstream_error: the provider failed; the hold was released and nothing was charged.

Keeping keys and data safe

  • Never put a key in front-end code or a public repository. Call the API from your server.
  • Create one key per application and give each a monthly cap, a model allow-list or an IP allow-list where that makes sense. You can revoke a key at any time; a revoked key stops working within seconds.
  • The gateway is designed not to store prompt or completion text. It records metadata such as the model, token counts, cost, status and latency. [[PLACEHOLDER: owner to confirm this statement before publication]]

More detail is in the documentation. Problems or questions can be sent through the contact page or to support@ticonai.com.

সব লেখা