Back to Blog
EnglishGuide

ERNIE Bot API Guide: Check the Exact Model ID Before Integrating

Four exact ERNIE identifiers were absent from this gateway credential catalog. An executable catalog and strict selection test shows the migration gate without claiming global ERNIE unavailability.

S
Sophie M
April 8, 2026 / 1725 views
Share:
ERNIE Bot API Guide: Check the Exact Model ID Before Integrating

Start with the exact ERNIE model identifier and the API account that will run the workload. In this gateway check, four names from earlier ERNIE examples were absent from the credential-visible catalog, so no generation was attempted under those names.

Crazyrouter catalog access was tested for four exact ERNIE names; none appeared for this credential, and four local selection cases passed. No ERNIE generation is claimed.

By Sophie M · Tested November 4, 2026

How can I verify an ERNIE API model before integrating it?#

The live request to /v1/models checked ernie-4.0-8k, ernie-4.0-turbo-8k, ernie-4.5-turbo-128k and ernie-4.5-300b-a47b. All four were absent. This does not say Baidu has retired the ERNIE family; Baidu documents newer ERNIE models separately. The article is a route-availability check for this credential, not a general Baidu tutorial.

November 4 test setup and observations#

The complete Python 3.10 script ran on Windows with a gateway credential held in the process environment. The request bodies, endpoints, response IDs, terminal states and failures are reproduced below. Script exit code zero means observations were saved; it does not turn an unsuccessful model response into a pass.

Requested exact model IDVisible to credential
ernie-4.0-8kNo; no call under this name
ernie-4.0-turbo-8kNo; no call under this name
ernie-4.5-turbo-128kNo; no call under this name
ernie-4.5-300b-a47bNo; no call under this name

No generation request was sent because none of the four exact ERNIE IDs was visible to this credential.

Executed local checkResult
exact namePassed
case mismatchPassed
different versionPassed
empty catalogPassed

ERNIE Bot API Guide: Check the Exact Model ID Before Integrating: observed route results for the stated fixtures

Do not translate old names into new ones without a decision#

The local selector uses exact string equality. Four executed fixtures cover an exact match, a capitalization mismatch, a different version and an empty catalog. Only the exact match is accepted. A newer or similarly named model might have different behavior, prices or limits. Put an explicit mapping in your deployment configuration only after testing the selected route.

What to do when the named route is missing#

Stop before generation, show the missing ID, inspect the current model directory and select a supported route deliberately. Then run a small task with the actual target model, inspect completion, usage and output, and test failure handling. This run stopped at the catalog gate and therefore contains no ERNIE generation response or latency measurement. The old article’s current-tense model lineup and cost claims are not carried forward as tested facts.

Reproduce this check#

Install requests, set CRAZYROUTER_API_KEY for an authorized account, and run this complete script with Python 3.10 or later. It may generate billable traffic. The script does not print authorization headers.

python
import json
import os
import time
from decimal import Decimal as D
import requests

BASE = "https://api.crazyrouter.com/v1"

def client():
    s = requests.Session()
    s.trust_env = False
    return s

def catalog(wanted):
    with client() as s:
        r = s.get(BASE + "/models", headers={"Authorization": "Bearer " + os.environ["CRAZYROUTER_API_KEY"]}, timeout=(10, 40), allow_redirects=False)
        r.raise_for_status()
        names = {x["id"] for x in r.json()["data"]}
    return {name: name in names for name in wanted}

def request(model, prompt, mode="chat", **options):
    path = {"chat": "/chat/completions", "messages": "/messages", "responses": "/responses"}[mode]
    payload = {"model": model, **options}
    if mode == "responses":
        payload["input"] = prompt
    else:
        payload["messages"] = [{"role": "user", "content": prompt}]
    headers = {"Authorization": "Bearer " + os.environ["CRAZYROUTER_API_KEY"]}
    if mode == "messages":
        headers = {"x-api-key": os.environ["CRAZYROUTER_API_KEY"], "anthropic-version": "2023-06-01"}
    rec = {"model": model, "endpoint": BASE + path, "request": payload}
    start = time.perf_counter()
    try:
        with client() as s:
            r = s.post(BASE + path, headers=headers, json=payload, timeout=(10, 90), allow_redirects=False)
        rec["http"] = r.status_code
        if r.status_code == 200:
            data = r.json()
            rec.update(response_id=data.get("id"), usage=data.get("usage", {}))
            if mode == "messages":
                output = "".join(x.get("text", "") for x in data.get("content", []) if x.get("type") == "text")
                complete = data.get("stop_reason") == "end_turn"
                finish = data.get("stop_reason")
            elif mode == "responses":
                output = "".join(c.get("text", "") for item in data.get("output", []) if item.get("type") == "message" for c in item.get("content", []) if c.get("type") == "output_text")
                complete = data.get("status") == "completed"
                finish = data.get("status")
            else:
                choice = data["choices"][0]
                output = choice["message"].get("content") or ""
                complete = choice.get("finish_reason") == "stop"
                finish = choice.get("finish_reason")
            rec.update(output=output, complete=complete, finish=finish)
        else:
            rec["error"] = "HTTP_" + str(r.status_code)
    except (requests.RequestException, ValueError, KeyError, IndexError) as error:
        rec["error"] = type(error).__name__
    rec["seconds"] = round(time.perf_counter() - start, 3)
    return rec

def accepted(rec, expected):
    if not rec.get("complete"):
        return False
    try:
        return json.loads(rec["output"]) == expected
    except (ValueError, TypeError):
        return False

def emit(**data):
    print(json.dumps(data, ensure_ascii=False))

def choose_exact(names, wanted):
    if wanted not in names:
        raise ValueError("Requested model is absent; no implicit substitute")
    return wanted

tests = []
for label, names, wanted, good in [
    ("exact name", {"ernie-4.0-8k"}, "ernie-4.0-8k", True),
    ("case mismatch", {"ERNIE-4.0-8K"}, "ernie-4.0-8k", False),
    ("different version", {"ernie-4.5-turbo-128k"}, "ernie-4.0-8k", False),
    ("empty catalog", set(), "ernie-4.0-8k", False)]:
    try:
        outcome = choose_exact(names, wanted) == wanted
    except ValueError:
        outcome = False
    assert outcome == good
    tests.append({"case": label, "passed": True})
wanted = ["ernie-4.0-8k", "ernie-4.0-turbo-8k", "ernie-4.5-turbo-128k", "ernie-4.5-300b-a47b"]
available = catalog(wanted)
rows = []
for model in wanted:
    if not available[model]:
        continue
    rec = request(model, 'Translate only: 订单已发货. Return exactly: Order shipped.', max_tokens=128)
    rec.update(case="bilingual smoke test", passed=rec.get("complete", False) and rec.get("output", "").strip() == "Order shipped.")
    rows.append(rec)
emit(local_tests=tests, catalog=available, requests=rows, scope="Four exact identifiers checked; no claim that the entire ERNIE family is unavailable globally")

ERNIE Bot API Guide: Check the Exact Model ID Before Integrating: local checks or observed usage and estimates

Documentation checked November 4, 2026: Baidu ERNIE model announcement, PaddlePaddle ERNIE repository. The test table describes gateway observations, not vendor-native account measurements.

FAQ#

Did any ERNIE model generate text in this run?#

No. None of the four requested identifiers was visible to this credential.

Does absence mean Baidu retired ERNIE?#

No. It describes one gateway account’s catalog at test time.

Can capitalization be ignored?#

Not in this selector. Exact IDs are required.

Should an old ID be replaced silently?#

No. A replacement needs an explicit choice and a new integration test.

Was the Baidu native API called?#

No. This was a gateway catalog check plus local selection tests.

What can I test next?#

Choose an available exact route, then verify a small generation request and application acceptance.

Last actually tested: November 4, 2026. This API-dependent article is due for review December 4, 2026.

Implementation Guides

Podcast

AI Dev Tools: The Crazyrouter Podcast

Short episodes for developers on AI APIs, gateways, cost control and coding tools.

Latest episodes

  • EP196 · Oct 29, 2026 · 6:53

    AI API Security Posture — Turn Controls Into Continuous Evidence

    A practical guide to AI API security posture: inventory exposure, verify controls continuously, protect keys and data, constrain tools, and turn security assumptions into evidence that operators can act on.

  • EP195 · Oct 28, 2026 · 7:21

    AI API Policy Drift — Detect When Production Rules Stop Matching Intent

    A practical guide to policy drift in AI APIs: version routing and safety rules, detect stale enforcement, compare intended and observed behavior, and restore control before small gaps become incidents.

Episodes with written show notes →

Topics

Related Articles