Overview

The MNN API is a powerful cloud-based API for integrating advanced AI capabilities, including natural language processing, image generation, speech recognition, and more into your applications. It offers RESTful endpoints for tasks like text generation, embeddings, and content moderation, with support for a variety of models tailored to specific use cases.

Quickstart

To quickly get started with the MNN API, begin by installing the OpenAI client library. Since the MNN API is fully compatible with OpenAI, you can use the same interface by simply changing the base_url to https://api.mnnai.ru/v1/. Make sure to get your API key and set it as an environment variable.

Here's a basic example:

                    from openai import OpenAI

client = OpenAI(
    base_url="https://api.mnnai.ru/v1"
)

completion = client.chat.completions.create(
    model="gpt-4.1",
    messages=[
        {
            "role": "user",
            "content": "Give me a short panda story"
        }
    ]
)

print(completion.choices[0].message.content)
                    

To run this code, first install the library: pip install openai.

Models

MNN offers a range of models for different tasks. For text, models like gpt-4.1 and gemini-2.5-pro-preview-05-06 excel in chat and reasoning tasks. For images, DALL·E 3 generates high-quality visuals. Whisper handles audio transcription. Each model is optimized for specific use cases, with trade-offs in speed, cost, and capability.

Example model list request:

from openai import OpenAI

client = OpenAI(
    base_url="https://api.mnnai.ru/v1"
)

models = client.models.list()

for model in models.data:
    print(model.id)

Pricing

MNN api is based on subscriptions that give credits per month. To learn more about each subscription, please visit the main page.

Text Generation

With the MNN API, you can use LLMs to generate any text - from code and mathematical expressions to structured JSON or human-like text.

{{ showResponses ? 'Chat Completions API' : 'Responses API' }}
from openai import OpenAI

client = OpenAI(
    base_url="https://api.mnnai.ru/v1"
)

response = client.chat.completions.create(
    model="mistral-medium-latest",
    messages=[
        {"role": "user", "content": "Summarize this: [long text]"}
    ],
    temperature=0.7
)

print(response.choices[0].message.content)
from openai import OpenAI

client = OpenAI(
    base_url="https://api.mnnai.ru/v1"
)

response = client.responses.create(
    model="mistral-medium-latest",
    input="Write a one-sentence bedtime story about a hypercorn."
)

print(response.output_text)

Reasoning

MNN API supports reasoning models such as o4-mini, gemini-2.5-pro. Reasoning models think before they respond, creating a long internal chain of thoughts before responding to the user. Reasoning models excel at complex problem solving, coding, scientific reasoning, and multi-step planning of agent workflows.

{{ showResponses ? 'Chat Completions API' : 'Responses API' }}
from openai import OpenAI

client = OpenAI(
    base_url="https://api.mnnai.ru/v1"
)

prompt = """
Write a bash script that takes a matrix represented as a string with
format '[1,2],[3,4],[5,6]' and prints the transpose in the same format.
"""

response = client.chat.completions.create(
    model="o4-mini",
    reasoning_effort="medium",
    messages=[
        {
            "role": "user",
            "content": prompt
        }
    ]
)

print(response.choices[0].message.content)
from openai import OpenAI

client = OpenAI(
    base_url="https://api.mnnai.ru/v1"
)

prompt = """
Write a bash script that takes a matrix represented as a string with
format '[1,2],[3,4],[5,6]' and prints the transpose in the same format.
"""

response = client.responses.create(
    model="o4-mini",
    reasoning={"effort": "medium"},
    input=[
        {
            "role": "user",
            "content": prompt
        }
    ]
)

print(response.output_text)

In the example above, the reasoning effort parameter guides the model on how many reasoning tokens to generate before creating a response to the prompt. Specify low, medium, or high for this parameter, where low favors speed and economical token usage, and high favors more complete reasoning. The default value is medium, which is a balance between speed and reasoning accuracy.

Deep research

With the MNN API, you can use deep research models for complex analysis and research tasks.

from openai import OpenAI

client = OpenAI(
    base_url="https://api.mnnai.ru/v1",
    timeout=3600
)

input_text = """
Research the economic impact of semaglutide on global healthcare systems.
Do:
- Include specific figures, trends, statistics, and measurable outcomes.
- Prioritize reliable, up-to-date sources: peer-reviewed research, health
  organizations (e.g., WHO, CDC), regulatory agencies, or pharmaceutical
  earnings reports.
- Include inline citations and return all source metadata.

Be analytical, avoid generalities, and ensure that each section supports
data-backed reasoning that could inform healthcare policy or financial modeling.
"""

response = client.responses.create(
  model="sonar-deep-research",
  input=input_text,
  tools=[
    {"type": "web_search_preview"},
    {"type": "code_interpreter", "container": {"type": "auto"}},
  ],
)

print(response.output_text)

Images

Some models generate images from text prompts. Example of generating an image:

from openai import OpenAI

client = OpenAI(
    base_url="https://api.mnnai.ru/v1"
)

response = client.images.generate(
    model="dall-e-3",
    prompt="A futuristic city at sunset",
    extra_body={"enhance": True} # If this parameter is specified, your prompt will be automatically enhanced
)

print(response.data[0].url)

Note: The API also supports the size parameter. But not all models support this parameter. To find out which models support it, visit the models page.

Image edit

Creates an edited image by specifying one image and a prompt:

from openai import OpenAI

client = OpenAI(
    base_url="https://api.mnnai.ru/v1"
)

response = client.images.edit(
    model="flux-kontext-pro",
    image=open("cat.png", "rb"),
    prompt="Change the background of the image to space",
    response_format="url"
)
print(response.data[0].url)

Image upscale

With MNN api you can improve the quality of your images:

from openai import OpenAI

client = OpenAI(
    base_url="https://api.mnnai.ru/v1"
)

response = client.images.edit(
    model="ideogram-upscale",
    image=open("image.png", "rb"),
    prompt="upscale",
    response_format="url"
)
print(response.data[0].url)

Vision

Vision models like gpt-4.1 analyze images for tasks like object detection, captioning, or answering questions about visual content. Example of image analysis:

{{ showVisionResponses ? 'Chat Completions API' : 'Responses API' }}
from openai import OpenAI

client = OpenAI(
    base_url="https://api.mnnai.ru/v1"
)

response = client.chat.completions.create(
    model="gpt-4.1-mini",
    messages=[{
        "role": "user",
        "content": [
            {"type": "text", "text": "What's in this image?"},
            {
                "type": "image_url",
                "image_url": {
                    "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg",
                },
            },
        ],
    }],
)

print(response.choices[0].message.content)
from openai import OpenAI

client = OpenAI(
    base_url="https://api.mnnai.ru/v1"
)

response = client.responses.create(
    model="gpt-4.1-mini",
    input=[{
        "role": "user",
        "content": [
            {"type": "input_text", "text": "what's in this image?"},
            {
                "type": "input_image",
                "image_url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg",
            },
        ],
    }],
)

print(response.output_text)

Speech to text

The Whisper model transcribes audio to text, supporting multiple languages and formats (e.g., MP3, WAV). Example of audio transcription:

from openai import OpenAI

client = OpenAI(
    base_url="https://api.mnnai.ru/v1"
)

with open("audio.mp3", "rb") as audio_file:
    transcription = client.audio.transcriptions.create(
        model="whisper-1",
        file=audio_file
    )

print(transcription.text)

Models such as GPT-4o or GPT-4o mini are natively multimodal, meaning they can understand and generate multiple modalities as input and output. If you already have a text-based LLM application with the Chat Completions endpoint, you may want to add audio capabilities. For example, if your chat application supports text input, you can add audio input and output—just include audio in the modalities array and use an audio model, like gpt-4o-audio-preview

Audio output from model:

from openai import OpenAI
import base64

client = OpenAI(
    base_url="https://api.mnnai.ru/v1"
)

completion = client.chat.completions.create(
    model="gpt-4o-audio-preview",
    modalities=["text", "audio"],
    audio={"voice": "alloy", "format": "wav"},
    messages=[
        {
            "role": "user",
            "content": "Is a golden retriever a good family dog?"
        }
    ]
)

print(completion.choices[0])

wav_bytes = base64.b64decode(completion.choices[0].message.audio.data)
with open("dog.wav", "wb") as f:
    f.write(wav_bytes)

Audio input to model:

from openai import OpenAI
import requests
import base64

client = OpenAI(
    base_url="https://api.mnnai.ru/v1"
)

# Fetch the audio file and convert it to a base64 encoded string
url = "https://cdn.openai.com/API/docs/audio/alloy.wav"
response = requests.get(url)
response.raise_for_status()
wav_data = response.content
encoded_string = base64.b64encode(wav_data).decode('utf-8')

completion = client.chat.completions.create(
    model="gpt-4o-audio-preview",
    modalities=["text", "audio"],
    audio={"voice": "alloy", "format": "wav"},
    messages=[
        {
            "role": "user",
            "content": [
                {
                    "type": "text",
                    "text": "What is in this recording?"
                },
                {
                    "type": "input_audio",
                    "input_audio": {
                        "data": encoded_string,
                        "format": "wav"
                    }
                }
            ]
        },
    ]
)

print(completion.choices[0].message)

Create translation

The Whisper model translates spoken audio into English, supporting various input formats (e.g., MP3, WAV) and a wide range of source languages. Example of audio translation:

from openai import OpenAI

client = OpenAI(
    base_url="https://api.mnnai.ru/v1"
)

with open("audio.mp3", "rb") as audio_file:
    transcription = client.audio.translations.create(
        model="whisper-1",
        file=audio_file
    )

print(transcription.text)

Text to speech

With MNN, you can convert text to speech. Here's an example:

from openai import OpenAI
from pathlib import Path

client = OpenAI(
    base_url="https://api.mnnai.ru/v1"
)

speech_file_path = Path(__file__).parent / "speech.mp3"

with client.audio.speech.with_streaming_response.create(
    model="gemini-2.5-flash-preview-tts",
    voice="Kore",
    input="The quick brown fox jumped over the lazy dog."
) as response:
    response.stream_to_file(speech_file_path)

Moderation

The Moderation endpoint checks text for harmful or inappropriate content, returning flags for categories like hate or violence. Example:

from openai import OpenAI

client = OpenAI(
    base_url="https://api.mnnai.ru/v1"
)

response = client.moderations.create(input="This is a safe sentence.")
print(response.results[0].flagged)

Embedding

Generate text embeddings with models like text-embedding-3-large for semantic search, clustering, or recommendations. Example:

from openai import OpenAI

client = OpenAI(
    base_url="https://api.mnnai.ru/v1"
)

response = client.embeddings.create(
  model="text-embedding-3-small",
  input="The quick brown fox jumps over the lazy dog"
)

print(response.data[0].embedding)

Function Calling

Function calling provides a powerful and flexible way for some models to interface with your code or external services. This guide will explain how to connect the models to your own custom code to fetch data or take action.

{{ showResponses ? 'Chat Completions API' : 'Responses API' }}
from openai import OpenAI

client = OpenAI(
    base_url="https://api.mnnai.ru/v1"
)

tools = [{
    "type": "function",
    "function": {
        "name": "get_weather",
        "description": "Get current temperature for a given location.",
        "parameters": {
            "type": "object",
            "properties": {
                "location": {
                    "type": "string",
                    "description": "City and country e.g. Bogotá, Colombia"
                }
            },
            "required": [
                "location"
            ],
            "additionalProperties": False
        },
        "strict": True
    }
}]

completion = client.chat.completions.create(
    model="gpt-4.1",
    messages=[{"role": "user", "content": "What is the weather like in Paris today?"}],
    tools=tools
)

print(completion.choices[0].message.tool_calls)
from openai import OpenAI

client = OpenAI(
    base_url="https://api.mnnai.ru/v1"
)

tools = [{
    "type": "function",
    "name": "get_weather",
    "description": "Get current temperature for a given location.",
    "parameters": {
        "type": "object",
        "properties": {
            "location": {
                "type": "string",
                "description": "City and country e.g. Bogotá, Colombia"
            }
        },
        "required": [
            "location"
        ],
        "additionalProperties": False
    }
}]

response = client.responses.create(
    model="gpt-4.1",
    input=[{"role": "user", "content": "What is the weather like in Paris today?"}],
    tools=tools
)

print(response.output)

Note: To use this feature, your subscription level must be 'Basic' or higher. To check whether a model supports function calling, visit the models page and look for the function_calling parameter.

Web Access

Web search allows AI to access information from the internet in real time to provide relevant answers, check facts, and find details beyond the training data. All MNN models support this feature because we use a proprietary search engine. Example:

from openai import OpenAI

client = OpenAI(
    base_url="https://api.mnnai.ru/v1"
)

response = client.responses.create(
    model="gpt-4o",
    tools=[{"type": "web_search_preview"}],
    input="What was a positive news story from today?"
)

print(response.output_text)

Note: To use search with the Chat Completions API add -search to the model name. For example deepseek-v3-0324-search.