Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions bot/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
openai_api_base = config_yaml.get("openai_api_base", None)
openrouter_api_key = config_yaml.get("openrouter_api_key", None)
openrouter_api_base = config_yaml.get("openrouter_api_base", "https://openrouter.ai/api/v1")
astraflow_api_key = config_yaml.get("astraflow_api_key", None)
astraflow_api_base = config_yaml.get("astraflow_api_base", "https://api-us-ca.umodelverse.ai/v1")
allowed_telegram_usernames = config_yaml["allowed_telegram_usernames"]
new_dialog_timeout = config_yaml["new_dialog_timeout"]
enable_message_streaming = config_yaml.get("enable_message_streaming", True)
Expand Down
16 changes: 16 additions & 0 deletions bot/openai_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,27 @@
base_url=config.openrouter_api_base,
)

# optional Astraflow client (OpenAI-compatible) for models declared with
# "provider: astraflow" in config/models.yml
astraflow_client = None
if config.astraflow_api_key:
astraflow_client = AsyncOpenAI(
api_key=config.astraflow_api_key,
base_url=config.astraflow_api_base,
)

logger = logging.getLogger(__name__)


def _get_client_for_model(model):
provider = config.models["info"].get(model, {}).get("provider", "openai")
if provider == "astraflow":
if astraflow_client is None:
raise ValueError(
"Astraflow API key is not configured. "
"Set astraflow_api_key in config/config.yml"
)
return astraflow_client
if provider == "openrouter":
if openrouter_client is None:
raise ValueError(
Expand Down
2 changes: 2 additions & 0 deletions config/config.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ openai_api_key: ""
openai_api_base: null # leave null to use default api base or you can put your own base url here
openrouter_api_key: "" # optional: needed only for models with "provider: openrouter" in models.yml (e.g. Claude)
openrouter_api_base: "https://openrouter.ai/api/v1" # OpenRouter is OpenAI-compatible; change only if you proxy it
astraflow_api_key: "" # optional: needed only for models with "provider: astraflow" in models.yml; global endpoint
astraflow_api_base: "https://api-us-ca.umodelverse.ai/v1" # Astraflow global endpoint; use https://api.modelverse.cn/v1 for China
allowed_telegram_usernames: [] # if empty, the bot is available to anyone. pass a username string to allow it and/or user ids as positive integers and/or channel ids as negative integers
new_dialog_timeout: 600 # new dialog starts after timeout (in seconds)
return_n_generated_images: 1 # number of images per /imagine request (gpt-image-1 supports more than one)
Expand Down
32 changes: 31 additions & 1 deletion config/models.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
available_text_models: ["gpt-4o-mini", "openai/gpt-5.5", "gpt-4o", "anthropic/claude-opus-4.8", "anthropic/claude-sonnet-latest", "anthropic/claude-haiku-latest"]
available_text_models: ["gpt-4o-mini", "openai/gpt-5.5", "gpt-4o", "anthropic/claude-opus-4.8", "anthropic/claude-sonnet-latest", "anthropic/claude-haiku-latest", "astraflow/gpt-4o", "astraflow/deepseek-r1"]

info:
gpt-4o:
Expand Down Expand Up @@ -89,6 +89,36 @@ info:
Fast: 5
Cheap: 4

astraflow/gpt-4o:
type: chat_completion
provider: astraflow
vision: true
name: GPT-4o (Astraflow)
description: GPT-4o routed via <b>Astraflow</b> — UCloud's OpenAI-compatible platform supporting 200+ models (requires astraflow_api_key).

price_per_1000_input_tokens: 0.0025
price_per_1000_output_tokens: 0.01

scores:
Smart: 5
Fast: 4
Cheap: 4

astraflow/deepseek-r1:
type: chat_completion
provider: astraflow
vision: false
name: DeepSeek R1 (Astraflow)
description: DeepSeek R1 routed via <b>Astraflow</b> — strong reasoning model at low cost (requires astraflow_api_key).

price_per_1000_input_tokens: 0.00055
price_per_1000_output_tokens: 0.00219

scores:
Smart: 5
Fast: 3
Cheap: 5

gpt-image-1:
type: image
price_per_1_image: 0.042 # 1024x1024, medium quality
Expand Down