Skip to main content

Model Capabilities

Large Language Models (LLMs) are artificial intelligence models based on deep learning and natural language processing technologies. Trained on vast amounts of text data, they can understand, generate, and process human language. Their main capabilities include:
  • Text Generation Can generate logically coherent text content based on context and adjust the output style as needed.
  • Language Understanding Can accurately understand the meaning of input text and support contextual conversations.
  • Text Translation Has cross-language generation and comprehension capabilities, enabling text translation between different languages.
  • Knowledge Q&A Has extensive knowledge reserves and can answer questions across various fields including culture, science, history, and more.
  • Code Understanding and Generation Can understand and generate code (such as Python, Java, C++, etc.), support identifying code errors, and provide code suggestions.
  • Text Classification and Summarization Can understand complex sentences, perform information classification and extraction, and extract key points from text for automatic summarization.

Model Selection

On Myrouter, you can view the list of supported large language models, learn about model introductions, pricing, and other information. Click on a specific model to open its detail page and try it online as needed. After thorough testing with your specific tasks, you can compare model performance and choose the most suitable model.

API Calls

Myrouter provides API services compatible with the OpenAI API standard, making it easy to integrate into your existing applications. If you are already using OpenAI’s ChatCompletion or Completion API, you only need to set the base URL to https://api.myrouter.ai/openai, obtain and set your API key, and update the model name as needed to access the large language model API service.
For how to obtain an API key, see Manage API Keys.

Code Examples

Python

from openai import OpenAI

client = OpenAI(
    base_url="https://api.myrouter.ai/openai",
    api_key="<Your API Key>",
)

model = "deepseek/deepseek-r1"
stream = True  # or False
max_tokens = 512

chat_completion_res = client.chat.completions.create(
    model=model,
    messages=[
        {
            "role": "system",
            "content": "You are a professional AI documentation assistant.",
        },
        {
            "role": "user",
            "content": "What scenarios can the models provided by Myrouter be used for?",
        }
    ],
    stream=stream,
    max_tokens=max_tokens,
)

if stream:
    for chunk in chat_completion_res:
        print(chunk.choices[0].delta.content or "", end="")
else:
    print(chat_completion_res.choices[0].message.content)

Curl

export API_KEY="<Your API Key>"

curl "https://api.myrouter.ai/openai/v1/chat/completions" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${API_KEY}" \
  -d '{
    "model": "deepseek/deepseek-r1",
    "messages": [
        {
            "role": "system",
            "content": "You are a professional AI documentation assistant."
        },
       {
            "role": "user",
            "content": "What scenarios can the models provided by Myrouter be used for?"
        }
    ],
    "max_tokens": 512
}'

Key Parameters

Basic Parameters

model: The model to call. You can view the list of supported large language models on Myrouter.

Message Roles

Only applicable to ChatCompletion.
messages: The input and output when interacting with the large model. Each message belongs to a role. Messages can help you get better outputs; you can try different approaches to achieve better results.
  • content: The message content.
  • role: The role of the message author.
    • system: Sets the AI role, telling the model what role or behavior to adopt.
    • user: Text input from the user to the model.
    • assistant: Responses generated by the model. Users can also pre-fill examples to tell the model how to respond to the current request.
  • name: Optional, used to distinguish message authors with the same role.

Prompt

Only applicable to Completion.
prompt: The prompt for generating completions. This is the text input from the user to the large language model, used to clearly tell the model the problem to solve or the task to complete. It is the foundation for the model to understand requirements and generate relevant, accurate content.

Generation Control

Different parameter combinations can make the model generate content that better meets specific needs. Text Diversity
Both temperature and top_p can control the diversity of generated text. It is recommended to set only one of them. Higher values produce more diverse text, while lower values produce more deterministic text.
  • temperature: Sampling temperature, adjusts the randomness of generated text.
  • top_p: Nucleus sampling, controls the cumulative probability of candidate tokens.
  • top_k: Limits the number of candidate tokens.
Content Repetition
  • presence_penalty: Presence penalty, controls the degree of content repetition when the model generates text. If a token has already appeared in the text, it will be penalized, encouraging the model to introduce more new tokens.
  • frequency_penalty: Frequency penalty, controls the occurrence frequency of certain words in generated text. Each time a token appears in the text, it is penalized, reducing the probability of those tokens in future generation and preventing the model from reusing the same tokens.
  • repetition_penalty: Repetition penalty value, used to suppress or encourage repetition.

Output Limits

  • max_tokens: The maximum number of tokens returned in a single request. If the model generates more tokens than the max_tokens value, the content will be truncated.
  • stream: Controls whether the output is streamed. For models that produce longer outputs, it is recommended to enable streaming to prevent output timeouts.
    • true: Streaming output, where content is returned incrementally as it is generated.
    • false: The model returns all content at once after generation is complete.
  • stop: Stop sequences. When the generated text contains a string set in stop, the model will stop outputting.