# lolmaobruhhh/mimo2api- architecture

> Architecture diagram of the GitHub repository lolmaobruhhh/mimo2api-, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lolmaobruhhh/mimo2api-
- Repository: https://github.com/lolmaobruhhh/mimo2api-

## Overview

MiMo2API is a FastAPI proxy that exposes MiMo AI Studio through OpenAI-compatible and Anthropic-compatible APIs. The main workflow accepts a client request, prepares messages and optional media/tools, sends it to MiMo, and returns a converted response or stream. Separate branches provide model discovery, account management, Anthropic batches, and usage/session tracking. Some relationships are supported by README architecture or module references rather than complete call-site excerpts; those limits are reflected in the edges.

Main entry points: [`app/routes.py`](https://github.com/lolmaobruhhh/mimo2api-/blob/main/app/routes.py) (OpenAI API and admin routes), [`main.py`](https://github.com/lolmaobruhhh/mimo2api-/blob/main/main.py) (FastAPI application), [`app/anthropic_routes.py`](https://github.com/lolmaobruhhh/mimo2api-/blob/main/app/anthropic_routes.py) (Anthropic endpoints), [`app/mimo_client.py`](https://github.com/lolmaobruhhh/mimo2api-/blob/main/app/mimo_client.py) (MiMo HTTP and SSE client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API interfaces"]
  node_main["FastAPI application<br/>[main.py]"]
  node_openai_routes["OpenAI API and admin routes<br/>[routes.py]"]
  node_anthropic_routes["Anthropic endpoints"]
  node_batch["Message batches<br/>[batch.py]"]
end

subgraph group_processing["Request processing"]
  node_anthropic_convert["Anthropic format conversion<br/>[anthropic.py]"]
  node_models["OpenAI data models<br/>[models.py]"]
  node_tool_sieve["Streaming tool sieve<br/>[tool_sieve.py]"]
  node_tool_call["Tool-call parsing<br/>[tool_call.py]"]
  node_message_utils["Message and media preparation<br/>[utils.py]"]
end

subgraph group_state["Configuration and state"]
  node_account_config["Accounts and settings<br/>[config.py]"]
  node_session_store[("Conversation sessions<br/>[session_store.py]")]
  node_usage_store[("Usage statistics<br/>[usage_store.py]")]
  node_response_store[("Response storage<br/>[response_store.py]")]
end

subgraph group_upstream["MiMo integration"]
  node_mimo_client["MiMo HTTP and SSE client<br/>[mimo_client.py]"]
end

node_client(("API client"))
node_admin_user(("Admin user"))
node_mimo_service{{"MiMo AI Studio"}}

node_client -->|"sends requests"| node_main
node_admin_user -->|"manages accounts"| node_openai_routes
node_main -->|"registers routes"| node_openai_routes
node_main -->|"registers routes"| node_anthropic_routes
node_main -->|"initializes batches"| node_batch
node_openai_routes -->|"proxies chat"| node_mimo_client
node_openai_routes -->|"streams filtered output"| node_tool_sieve
node_openai_routes -->|"parses tool calls"| node_tool_call
node_openai_routes -.->|"prepares messages"| node_message_utils
node_openai_routes -.->|"uses request models"| node_models
node_openai_routes -.->|"reads account settings"| node_account_config
node_openai_routes -.->|"tracks conversations"| node_session_store
node_openai_routes -.->|"records usage"| node_usage_store
node_openai_routes -.->|"stores responses"| node_response_store
node_anthropic_routes -->|"converts messages"| node_anthropic_convert
node_anthropic_routes -->|"calls MiMo"| node_mimo_client
node_anthropic_routes -.->|"serves batch APIs"| node_batch
node_batch -->|"converts batch requests"| node_anthropic_convert
node_mimo_client -->|"uses account credentials"| node_account_config
node_mimo_client -->|"sends chat requests"| node_mimo_service
node_message_utils -->|"uploads media"| node_mimo_service

click node_main "https://github.com/lolmaobruhhh/mimo2api-/blob/main/main.py"
click node_openai_routes "https://github.com/lolmaobruhhh/mimo2api-/blob/main/app/routes.py"
click node_anthropic_routes "https://github.com/lolmaobruhhh/mimo2api-/blob/main/app/anthropic_routes.py"
click node_anthropic_convert "https://github.com/lolmaobruhhh/mimo2api-/blob/main/app/anthropic.py"
click node_batch "https://github.com/lolmaobruhhh/mimo2api-/blob/main/app/batch.py"
click node_models "https://github.com/lolmaobruhhh/mimo2api-/blob/main/app/models.py"
click node_tool_sieve "https://github.com/lolmaobruhhh/mimo2api-/blob/main/app/tool_sieve.py"
click node_tool_call "https://github.com/lolmaobruhhh/mimo2api-/blob/main/app/tool_call.py"
click node_message_utils "https://github.com/lolmaobruhhh/mimo2api-/blob/main/app/utils.py"
click node_account_config "https://github.com/lolmaobruhhh/mimo2api-/blob/main/app/config.py"
click node_session_store "https://github.com/lolmaobruhhh/mimo2api-/blob/main/app/session_store.py"
click node_usage_store "https://github.com/lolmaobruhhh/mimo2api-/blob/main/app/usage_store.py"
click node_response_store "https://github.com/lolmaobruhhh/mimo2api-/blob/main/app/response_store.py"
click node_mimo_client "https://github.com/lolmaobruhhh/mimo2api-/blob/main/app/mimo_client.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_openai_routes,node_anthropic_routes,node_batch,node_client,node_admin_user toneBlue
class node_anthropic_convert,node_models,node_tool_sieve,node_tool_call,node_message_utils toneAmber
class node_account_config,node_session_store,node_usage_store,node_response_store toneMint
class node_mimo_client toneRose
class node_mimo_service toneIndigo
```

## Components

### API interfaces

- [FastAPI application](https://github.com/lolmaobruhhh/mimo2api-/blob/main/main.py): `main.py`
- [OpenAI API and admin routes](https://github.com/lolmaobruhhh/mimo2api-/blob/main/app/routes.py): `app/routes.py`
- [Anthropic endpoints](https://github.com/lolmaobruhhh/mimo2api-/blob/main/app/anthropic_routes.py): `app/anthropic_routes.py`
- [Message batches](https://github.com/lolmaobruhhh/mimo2api-/blob/main/app/batch.py): `app/batch.py`

### Request processing

- [Anthropic format conversion](https://github.com/lolmaobruhhh/mimo2api-/blob/main/app/anthropic.py): `app/anthropic.py`
- [OpenAI data models](https://github.com/lolmaobruhhh/mimo2api-/blob/main/app/models.py): `app/models.py`
- [Streaming tool sieve](https://github.com/lolmaobruhhh/mimo2api-/blob/main/app/tool_sieve.py): `app/tool_sieve.py`
- [Tool-call parsing](https://github.com/lolmaobruhhh/mimo2api-/blob/main/app/tool_call.py): `app/tool_call.py`
- [Message and media preparation](https://github.com/lolmaobruhhh/mimo2api-/blob/main/app/utils.py): `app/utils.py`

### Configuration and state

- [Accounts and settings](https://github.com/lolmaobruhhh/mimo2api-/blob/main/app/config.py): `app/config.py`
- [Conversation sessions](https://github.com/lolmaobruhhh/mimo2api-/blob/main/app/session_store.py): `app/session_store.py`
- [Usage statistics](https://github.com/lolmaobruhhh/mimo2api-/blob/main/app/usage_store.py): `app/usage_store.py`
- [Response storage](https://github.com/lolmaobruhhh/mimo2api-/blob/main/app/response_store.py): `app/response_store.py`

### MiMo integration

- [MiMo HTTP and SSE client](https://github.com/lolmaobruhhh/mimo2api-/blob/main/app/mimo_client.py): `app/mimo_client.py`

### Other components

- **API client**
- **Admin user**
- **MiMo AI Studio**

## Connections

- API client → FastAPI application: sends requests (evidence: `README.md`)
- Admin user → OpenAI API and admin routes: manages accounts (evidence: `README.md`)
- FastAPI application → OpenAI API and admin routes: registers routes (evidence: `main.py`)
- FastAPI application → Anthropic endpoints: registers routes (evidence: `main.py`)
- FastAPI application → Message batches: initializes batches (evidence: `main.py`)
- OpenAI API and admin routes → MiMo HTTP and SSE client: proxies chat (evidence: `README.md`)
- OpenAI API and admin routes → Streaming tool sieve: streams filtered output (evidence: `README.md`)
- OpenAI API and admin routes → Tool-call parsing: parses tool calls (evidence: `README.md`)
- OpenAI API and admin routes → Message and media preparation: prepares messages (evidence: `app/routes.py`)
- OpenAI API and admin routes → OpenAI data models: uses request models (evidence: `app/routes.py`)
- OpenAI API and admin routes → Accounts and settings: reads account settings (evidence: `app/routes.py`)
- OpenAI API and admin routes → Conversation sessions: tracks conversations (evidence: `app/routes.py`)
- OpenAI API and admin routes → Usage statistics: records usage (evidence: `app/routes.py`)
- OpenAI API and admin routes → Response storage: stores responses (evidence: `app/routes.py`)
- Anthropic endpoints → Anthropic format conversion: converts messages (evidence: `app/anthropic_routes.py`)
- Anthropic endpoints → MiMo HTTP and SSE client: calls MiMo (evidence: `app/anthropic_routes.py`)
- Anthropic endpoints → Message batches: serves batch APIs (evidence: `app/anthropic_routes.py`)
- Message batches → Anthropic format conversion: converts batch requests (evidence: `app/batch.py`)
- MiMo HTTP and SSE client → Accounts and settings: uses account credentials (evidence: `app/mimo_client.py`)
- MiMo HTTP and SSE client → MiMo AI Studio: sends chat requests (evidence: `README.md`)
- Message and media preparation → MiMo AI Studio: uploads media (evidence: `app/utils.py`)
