OpenAI-compatible Aistudio adapter.
Currently supported:
POST /v1/chat/completionsPOST /v1/filesGET /v1/models
This project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0-only).
If you modify this project and make it available to users over a network, you must also make the corresponding source code of your modified version available under the same license terms.
The runtime now uses managed accounts only.
- The server also auto-loads a local
.envfile when present - Set
MS2API_ADMIN_PASSWORDbefore starting the server - Open the admin panel at
/ - Add account credentials there
- Trigger login and enter the email verification code
- Export / import the managed account library as JSON when needed
- Only enabled managed accounts participate in request routing
Legacy cookie directories are kept only as login artifacts and are no longer auto-discovered for request handling.
Example .env:
MS2API_ADMIN_PASSWORD=change-me
MS2API_ADMIN_SESSION_SECRET=replace-this-tooYou can also start the container with --env-file .env, and the app will
still read the same variables at runtime.
The adapter now supports forwarding attachments to Aistudio.
Recommended flow:
- Upload a file to
POST /v1/files - Put the returned
file_idinto the last user message - Send
POST /v1/chat/completions
Example message payload:
{
"model": "mimo-v2-flash",
"messages": [
{
"role": "user",
"content": [
{ "type": "text", "text": "请总结附件内容" },
{ "type": "input_file", "file_id": "file_xxx" }
]
}
]
}Also supported:
- inline
input_file.file_dataviadata:URL - inline
image_url.urlviadata:URL
For security, remote http(s) attachment URLs are currently rejected.
GET /v1/models exposes Aistudio model name as the OpenAI-compatible
id.
Examples:
mimo-v2-flashmimo-v2-promimo-v2-omni
The adapter will map those public names back to the real upstream backend model identifiers automatically.
For chat models that support web search, the adapter also exposes a -search
variant in GET /v1/models.
Examples:
mimo-v2-flash→ search disabledmimo-v2-flash-search→ search enabledmimo-v2-pro→ search disabledmimo-v2-pro-search→ search enabled
Current behavior:
- The
-searchsuffix automatically sets upstreammodelConfig.webSearchStatus = "enabled" - The plain model ID keeps search disabled
- If the request contains attachments, search is still forced to
disabled - Omni models do not currently expose a
-searchvariant
GET /v1/models also includes:
web_search_enabledparent
The repository now includes a production Dockerfile.
Build locally:
docker build -t ms2api:local .Run locally:
docker run --rm -p 8000:8000 \
--env-file .env \
-v "$(pwd)/data:/data" \
ms2api:localContainer defaults:
- listens on
0.0.0.0:8000 - stores runtime data in
/data - keeps these paths persistent inside the mounted volume:
/data/accounts.json/data/aistudio-http-login/data/openai-files/data/logs
If you do not use --env-file, at minimum you should provide:
-e MS2API_ADMIN_PASSWORD=change-meThe repository now includes .github/workflows/docker.yml.
Behavior:
- triggers on every
push - can also be run manually with
workflow_dispatch - builds the Docker image from
Dockerfile - pushes it to GitHub Container Registry (
ghcr.io)
The published image name is based on the repository path:
ghcr.io/<owner>/<repo>
Common tags produced by the workflow:
- branch name
sha-<commit>lateston the default branch
Example pull:
docker pull ghcr.io/<owner>/<repo>:latestNotes:
- GitHub links the package to the repository automatically when it is first
published from this workflow using
GITHUB_TOKEN - The first published package is private by default on GHCR
- If the same GHCR package namespace was pushed manually before and was not connected to this repository, the workflow may not have permission to push until you connect or clean up that package in GitHub