Skip to content

feat: Add Astraflow LLM provider support (global & China endpoints)#2020

Open
ucloudnb666 wants to merge 3 commits into
FoundationAgents:mainfrom
ucloudnb666:feat/astraflow-1776820729
Open

feat: Add Astraflow LLM provider support (global & China endpoints)#2020
ucloudnb666 wants to merge 3 commits into
FoundationAgents:mainfrom
ucloudnb666:feat/astraflow-1776820729

Conversation

@ucloudnb666
Copy link
Copy Markdown

Summary

This PR adds Astraflow (by UCloud / 优刻得) as a supported LLM provider in MetaGPT.

Astraflow is an OpenAI-compatible AI model aggregation platform supporting 200+ models. It exposes two regional endpoints:

Variant Env Var Base URL
Global ASTRAFLOW_API_KEY https://api-us-ca.umodelverse.ai/v1
China ASTRAFLOW_CN_API_KEY https://api.modelverse.cn/v1

Sign up at: https://astraflow.ucloud.cn/


Changes

1. metagpt/configs/llm_config.py

  • Added ASTRAFLOW = "astraflow" and ASTRAFLOW_CN = "astraflow_cn" to the LLMType enum.

2. metagpt/provider/astraflow_api.py (new file)

  • Created AstraflowLLM — a thin subclass of OpenAILLM registered for both LLMType.ASTRAFLOW and LLMType.ASTRAFLOW_CN.
  • Automatically sets the correct base_url based on the api_type when none is explicitly configured.

3. metagpt/provider/__init__.py

  • Imported and exported AstraflowLLM.

Usage

Global endpoint (config2.yaml):

llm:
  api_type: "astraflow"
  api_key: "YOUR_ASTRAFLOW_API_KEY"   # env: ASTRAFLOW_API_KEY
  model: "YOUR_MODEL_NAME"            # e.g. gpt-4o, claude-3-5-sonnet, etc.

China endpoint (config2.yaml):

llm:
  api_type: "astraflow_cn"
  api_key: "YOUR_ASTRAFLOW_CN_API_KEY"  # env: ASTRAFLOW_CN_API_KEY
  model: "YOUR_MODEL_NAME"

Both variants inherit all capabilities of OpenAILLM (streaming, tool calls, image generation, cost tracking, etc.) since Astraflow is fully OpenAI-compatible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant