AIWave API

ERNIE 4.0

Model ID updated. ernie-4 is no longer served. This page now documents ernie-4.0-8k, the current model in the same family. See the full directory for every available ID.
Knowledge

ERNIE 4.0 is Baidu's most advanced model. Strong knowledge retrieval and factual accuracy. Great for enterprise knowledge management and Q&A systems.

Model Details

ProviderBaidu
Input Price$0.0045 per 1M tokens
Output Price$0.0045 per 1M tokens
Context Window128K tokens
AIWave Endpointernie-4.0-8k

Use Cases

Knowledge Q&A Enterprise Accuracy Factual
API Docs → Compare Pricing →

Quick Start

curl https://aiwave.live/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{"model":"ernie-4","messages":[{"role":"user","content":"Hello!"}]}'

What it costs in practice

These figures come straight from the live rate above — monthly token volume multiplied by the per-million price. Adjust the volumes to match your own traffic.

WorkloadAssumptionMonthly tokensMonthly cost
Chatbot~50k short conversations5.0M in / 1.5M out$0.03
Coding assistantone developer, full-time20.0M in / 4.0M out$0.11
RAG / document Q&Along retrieved contexts50.0M in / 2.0M out$0.24

Rates are pulled from the live pricing endpoint. Token accounting is returned in the usage field of every non-streaming response.

Quick start

The endpoint is OpenAI-compatible, so the official SDKs work once you change base_url. Nothing else in your code needs to move.

from openai import OpenAI

client = OpenAI(
    api_key="sk-YOUR_KEY",
    base_url="https://aiwave.live/v1",
)

response = client.chat.completions.create(
    model="ernie-4.0-8k",
    messages=[{"role": "user", "content": "Hello"}],
)
print(response.choices[0].message.content)
print(response.usage)   # exact token counts for cost tracking

Streaming uses the same server-sent-event format as OpenAI:

stream = client.chat.completions.create(
    model="ernie-4.0-8k",
    messages=[{"role": "user", "content": "Explain vector search"}],
    stream=True,
)
for chunk in stream:
    delta = chunk.choices[0].delta.content
    if delta:
        print(delta, end="", flush=True)

Node.js, LangChain, LlamaIndex, the Vercel AI SDK, Cursor and Cline all accept a custom base URL, so they work with this model without a dedicated provider plugin. Full parameter reference lives in the Chat Completions docs.

How it compares to sibling models

Same provider, same API surface — the practical difference is price and capability. Because every model here speaks the OpenAI wire format, switching between them is a one-word change to the model field.

Model IDInput / 1MOutput / 1M
ernie-char-8k$0.0006$0.0006
ernie-novel-8k$0.0006$0.0006
ernie-char-fiction-8k$0.0006$0.0006
ernie-speed-8k$0.0006$0.0006
ernie-lite-8k$0.0006$0.0006
ernie-4.0-turbo-8k$0.0012$0.0012

Where to go next

Get an API key →Compare pricing →

Related Models

Try ERNIE 4.0 with $1 Free →