Universe Developer Guide
Welcome to Universe! This guide will help you make your first API call in 5 minutes and gain a comprehensive understanding of the platform's core capabilities and development approaches.
Platform Overview
Universe is a one-stop AI large model API service platform, providing developers with feature-rich, flexible, and easy-to-use large language model calling capabilities. The platform covers a range of models from lightweight and efficient to flagship all-in-one, supporting various application scenarios such as text generation, conversational interaction, code assistance, and content creation.
Core Advantages
| Advantage | Description |
|---|---|
| Rich Model Portfolio | Offers three models with distinct positioning: Universe 3.0 / 3.0 Pro / 4.5, covering a wide range of scenario requirements. |
| Complete Development Toolkit | Official Python SDK, Java SDK, OpenAI-compatible interface, and LangChain integration -- ready to use out of the box. |
| Exceptional Cost-Effectiveness | Token-based billing with Prompt Cache support; cache hits can save approximately 97%-99% on input costs. |
| Reliable Service Guarantee | High-concurrency resources, multi-layer security protection, and 99.9% service availability guarantee. |
Quick Start
Follow these four steps to complete your API integration in minutes.
Step 1: Obtain an API Key
The API Key is the identity credential for calling Universe API. Follow these steps to obtain one:
- Visit the Universe API Console, register, and log in.
- Navigate to the API Keys Management Page.
- Click "Create New Key", then copy and securely store the generated Key.
Security Reminder: Do not hardcode your API Key in source code or commit it to public repositories. It is recommended to manage it via environment variables:
export UNIVERSE_API_KEY="sk-xxxxxxxxxxxxxxxxxxxxxxxx"
Step 2: Install the SDK
Choose the installation method that matches your tech stack:
Python SDK (Python 3.8+ recommended):
pip install universeai
Java SDK (Maven):
<dependency>
<groupId>com.universeai</groupId>
<artifactId>universeai-java-sdk</artifactId>
<version>1.0.0</version>
</dependency>
OpenAI SDK Compatible Mode (for migration from OpenAI):
pip install openai
Step 3: Send Your First Request
Below is the simplest call example -- sending a message to the model and receiving a reply:
Python:
from universeai import UniverseClient
client = UniverseClient(api_key="YOUR_API_KEY")
response = client.chat.completions.create(
model="universe-3.0-pro",
messages=[
{"role": "system", "content": "You are a helpful AI assistant."},
{"role": "user", "content": "Hello, please introduce yourself in one sentence."}
]
)
print(response.choices[0].message.content)
cURL:
curl -X POST "https://open.universeapi.com/api/paas/v4/chat/completions" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "universe-3.0-pro",
"messages": [
{"role": "system", "content": "You are a helpful AI assistant."},
{"role": "user", "content": "Hello, please introduce yourself in one sentence."}
]
}'
Java:
UniverseClient client = UniverseClient.builder().apiKey("YOUR_API_KEY").build();
ChatCompletionCreateParams request = ChatCompletionCreateParams.builder()
.model("universe-3.0-pro")
.messages(Arrays.asList(
ChatMessage.builder().role("system").content("You are a helpful AI assistant.").build(),
ChatMessage.builder().role("user").content("Hello, please introduce yourself in one sentence.").build()
))
.build();
ChatCompletionResponse response = client.chat().createChatCompletion(request);
System.out.println(response.getData().getChoices().get(0).getMessage());
Step 4: Integrate into Your Application
After successfully receiving your first response, you can:
- Wrap API calls into backend services and connect them to frontend applications
- Use streaming output (
stream=true) to achieve a real-time typewriter effect - Customize the model's role and behavior with System Prompt
- Refer to the Prompt Engineering Guide to optimize output quality
Tip: If you are building programming-related products such as code assistants or IDE plugins, use the dedicated coding endpoint
https://open.universeapi.com/api/coding/paas/v4for better code generation results. See the API Reference for details.
Development Methods
Universe API provides multiple integration methods to meet the needs of different tech stacks and scenarios.
| Integration Method | Description | Applicable Scenarios | Difficulty |
|---|---|---|---|
| HTTP RESTful API | Standard HTTP requests, language-agnostic | Any tech stack | Low |
| Python SDK | Official toolkit, supports sync/async | Python projects | Low |
| Java SDK | Enterprise-grade toolkit, supports high concurrency | Java/Spring projects | Low |
| OpenAI-Compatible Interface | Compatible with OpenAI SDK protocol | Migrating from OpenAI | Very Low |
| LangChain Integration | Native support for the LangChain framework | AI Agent / RAG applications | Medium |
Migrating from OpenAI
Seamlessly migrate by modifying just two parameters:
from openai import OpenAI
client = OpenAI(
api_key="YOUR_UNIVERSE_API_KEY",
base_url="https://open.universeapi.com/api/paas/v4"
)
# The rest of the code remains unchanged
response = client.chat.completions.create(
model="universe-3.0-pro",
messages=[{"role": "user", "content": "Hello"}]
)
LangChain Integration
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
model="universe-3.0-pro",
api_key="YOUR_UNIVERSE_API_KEY",
base_url="https://open.universeapi.com/api/paas/v4"
)
response = llm.invoke("Introduce the core advantages of Universe API")
Core Concepts
API Key
The API Key is your identity credential, and every request must carry a valid Key. It is recommended to create separate Keys for different projects in the console and configure call rate limits and spending quota caps. See the access control section in the FAQ for details.
Token
A token is the smallest unit of text processing for the model and the fundamental unit of billing.
| Language | Approximate Conversion |
|---|---|
| Chinese | 1 Chinese character ≈ 1-2 tokens |
| English | 1 word ≈ 1-1.5 tokens |
Each API call response includes a usage field that records the exact number of tokens consumed in that request. For detailed billing information, please refer to Pricing.
Context Window
The context window is the maximum text length the model can process in a single conversation, including user input, model responses, and intermediate reasoning content. Content exceeding the limit will be automatically truncated.
Mitigation Strategies:
- Streamline input by removing unnecessary context
- Periodically summarize long conversations to compress historical information
- Choose a model with a larger context window (e.g., Universe 4.5)
System Prompt
The System Prompt is the highest-priority instruction in each conversation, used to define the model's role, behavioral patterns, and output specifications. A well-designed System Prompt can significantly improve the consistency and controllability of outputs. For detailed writing techniques, please refer to the Prompt Engineering Guide.
Streaming vs. Non-Streaming Output
| Mode | Parameter | Characteristics | Applicable Scenarios |
|---|---|---|---|
| Non-Streaming | stream=false (default) | Waits for generation to complete, then returns the full response at once | Backend batch processing, data extraction |
| Streaming | stream=true | Pushes tokens in real time as they are generated | Chat conversations, real-time interaction |
Available Models
| Model | Positioning | Key Features | Applicable Scenarios |
|---|---|---|---|
| Universe 3.0 | Lightweight & Efficient | Fast response, low cost | Everyday Q&A, text classification, batch generation |
| Universe 3.0 Pro | Professional & Enhanced | Strong reasoning, high cost-effectiveness | Content creation, code generation, data analysis |
| Universe 4.5 | Flagship & All-in-One | Highest capability ceiling | Complex reasoning, enterprise agents, professional consulting |
Not sure which to choose? We recommend starting with Universe 3.0 Pro -- it offers the best balance between capability and cost. For a detailed model comparison, see the Model Product Introduction.
Best Practices Overview
| Practice | Recommendation |
|---|---|
| Prompt Design | Provide clear, specific instructions that include background information and output format requirements. See the Prompt Engineering Guide for details. |
| Model Selection | Use lightweight models (3.0) for simple tasks and flagship models (4.5) only for complex tasks to reduce costs while maintaining quality. |
| Cost Control | Leverage the Prompt Cache mechanism, streamline input content, and set the max_tokens parameter appropriately. See Pricing for details. |
| Error Handling | Implement exponential backoff retry logic and properly handle 429 rate-limit and 5xx server errors. See the FAQ for details. |
| Key Security | Manage API Keys via environment variables, use separate Keys for different projects, and rotate them regularly. |
| Production Deployment | Use streaming output to optimize user experience, handle high concurrency via asynchronous calls, and set spending quota caps to prevent unexpected overspending. |
Documentation Navigation
| Document | Content |
|---|---|
| API Reference | Complete API reference: endpoints, parameters, response formats, error codes |
| Model Product Introduction | Capability positioning, core features, and model selection guide |
| Pricing | Billing rules, model pricing, Prompt Cache details, cost optimization |
| Prompt Engineering Guide | Prompt writing techniques, System Prompt design, parameter tuning |
| FAQ | FAQ, troubleshooting, error code details, SDK installation issues |
Encountering issues? Visit the Help Center or contact the technical support team via the feedback button in the top-right corner of the page.