Skip to main content

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

AdvantageDescription
Rich Model PortfolioOffers three models with distinct positioning: Universe 3.0 / 3.0 Pro / 4.5, covering a wide range of scenario requirements.
Complete Development ToolkitOfficial Python SDK, Java SDK, OpenAI-compatible interface, and LangChain integration -- ready to use out of the box.
Exceptional Cost-EffectivenessToken-based billing with Prompt Cache support; cache hits can save approximately 97%-99% on input costs.
Reliable Service GuaranteeHigh-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:

  1. Visit the Universe API Console, register, and log in.
  2. Navigate to the API Keys Management Page.
  3. 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/v4 for 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 MethodDescriptionApplicable ScenariosDifficulty
HTTP RESTful APIStandard HTTP requests, language-agnosticAny tech stackLow
Python SDKOfficial toolkit, supports sync/asyncPython projectsLow
Java SDKEnterprise-grade toolkit, supports high concurrencyJava/Spring projectsLow
OpenAI-Compatible InterfaceCompatible with OpenAI SDK protocolMigrating from OpenAIVery Low
LangChain IntegrationNative support for the LangChain frameworkAI Agent / RAG applicationsMedium

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.

LanguageApproximate Conversion
Chinese1 Chinese character ≈ 1-2 tokens
English1 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

ModeParameterCharacteristicsApplicable Scenarios
Non-Streamingstream=false (default)Waits for generation to complete, then returns the full response at onceBackend batch processing, data extraction
Streamingstream=truePushes tokens in real time as they are generatedChat conversations, real-time interaction

Available Models

ModelPositioningKey FeaturesApplicable Scenarios
Universe 3.0Lightweight & EfficientFast response, low costEveryday Q&A, text classification, batch generation
Universe 3.0 ProProfessional & EnhancedStrong reasoning, high cost-effectivenessContent creation, code generation, data analysis
Universe 4.5Flagship & All-in-OneHighest capability ceilingComplex 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

PracticeRecommendation
Prompt DesignProvide clear, specific instructions that include background information and output format requirements. See the Prompt Engineering Guide for details.
Model SelectionUse lightweight models (3.0) for simple tasks and flagship models (4.5) only for complex tasks to reduce costs while maintaining quality.
Cost ControlLeverage the Prompt Cache mechanism, streamline input content, and set the max_tokens parameter appropriately. See Pricing for details.
Error HandlingImplement exponential backoff retry logic and properly handle 429 rate-limit and 5xx server errors. See the FAQ for details.
Key SecurityManage API Keys via environment variables, use separate Keys for different projects, and rotate them regularly.
Production DeploymentUse streaming output to optimize user experience, handle high concurrency via asynchronous calls, and set spending quota caps to prevent unexpected overspending.

Documentation Navigation

DocumentContent
API ReferenceComplete API reference: endpoints, parameters, response formats, error codes
Model Product IntroductionCapability positioning, core features, and model selection guide
PricingBilling rules, model pricing, Prompt Cache details, cost optimization
Prompt Engineering GuidePrompt writing techniques, System Prompt design, parameter tuning
FAQFAQ, 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.