Knowledge base
Large language model basics
This article introduces the fundamentals of large language models and LLM APIs to provide useful background before you integrate them.
What is a large language model?
A large language model (LLM) is a deep-learning AI model trained on vast amounts of text to understand, generate and predict human language. Its key characteristics:
- Large parameter counts: From billions to trillions of parameters, with new capabilities emerging as scale grows.
- Pre-training: Large-scale self-supervised learning on general text establishes basic language and knowledge capabilities.
- Post-training and alignment: Instruction fine-tuning and human feedback then teach the model to follow instructions and meet safety expectations.
Common uses:
- Text generation: Write articles, emails, code and scripts.
- Question answering: Intelligent support and knowledge-base retrieval.
- Translation and summarization: Translate between languages and extract key information from long documents.
- Reasoning: Logical analysis, mathematical problem solving and task planning.
- Agents: Call tools, operate external systems and complete multi-step tasks automatically.
What is an LLM API?
An LLM API is a programming interface offered by a model provider, allowing applications to interact with models through HTTP requests. The basic flow is: application → HTTP request → API service → model inference → HTTP response → application.
OpenAI-compatible formats are widely used across the industry, including by Yomi API. The unified endpoint address is https://api.yomiapi.com/v1; include Authorization: Bearer <API_KEY> in the request headers for authentication. Mainstream SDKs work directly after changing base_url.
Main endpoint types
The platform's main endpoints below remain compatible with the OpenAI API specification:
| API | Endpoint | Typical use |
|---|---|---|
| Chat Completions | /v1/chat/completions | Chat, question answering and agents; most commonly used |
| Responses | /v1/responses | OpenAI Responses format |
| Native Claude | /v1/messages | Anthropic Messages format |
| Text completions | /v1/completions | Legacy text continuation, retained for compatibility |
| Images | /v1/images/generations/v1/images/edits | Text-to-image generation and image editing |
| Embeddings | /v1/embeddings | Vectors for semantic search and RAG |
| Audio | /v1/audio/* | Audio transcription, translation and synthesis |
| Content moderation | /v1/moderations | Text safety filtering |
| Reranking | /v1/rerank | Rerank retrieval results |
| Realtime API | /v1/realtime | WebSocket realtime conversations |
| Model list | /v1/models | Query available models |
The platform also provides native Gemini endpoints; see the API reference for their paths. Fine-tuning and Files management APIs are not currently supported.
Message roles
The messages array in a chat completion request contains messages with different roles:
| Role | Description | Purpose |
|---|---|---|
system | System message | Set the AI's behavior and rules |
user | User message | User input |
assistant | Assistant message | AI reply |
tool | Tool message | A tool call's return value |
Key parameters explained
temperature
Controls output randomness, commonly from 0 to 2:
- 0:Highly deterministic output, with similar results across repeated calls.
- 0.1-0.3:Low randomness, suitable for coding and factual questions.
- 0.7-0.9:Moderate randomness, suitable for creative writing.
- Above 1.0: High randomness, with more creativity but less consistency.
max_tokens (output limit)
Limits the tokens generated in one call to control cost and response length. Setting it too low can truncate the answer.
stop (stop sequences)
Specifies one or more markers that stop generation when encountered, often to constrain the output format.
stream (streaming output)
Set stream: true to receive the response in Server-Sent Events (SSE) chunks, displaying content before the full answer is generated. This is recommended for conversational applications.
Function calling
Use the tools parameter to declare available tool functions. The model decides when to call a function, which one to call and what arguments to provide. This supports data queries, external services and other interactions with outside systems.
Error handling
The API returns standard HTTP status codes. Common errors and handling:
| Error code | Description | Action |
|---|---|---|
| 400 | Invalid request format | Check parameters and request body |
| 401 | Authentication failed | Check that Authorization header and key |
| 403 | Insufficient permissions | Check account status and model permissions |
| 429 | Too many requests | Reduce the rate and retry with exponential backoff |
| 500 | Server error | Try again later |
| 503 | Service unavailable | Try again later |
Rate limits vary by model and route. Refer to the route information in the Model Catalog.
Tokens and billing
A token is the smallest unit of text processed by a model. A common English word is roughly one token, and a Chinese character is roughly one to two tokens.
The platform uses pay-as-you-go billing with no monthly fee: cost = input tokens × input price + output tokens × output price. Prices vary by model. See Usage in the User Center for spending details.
