polyrob 0.5.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- agents/README.md +453 -0
- agents/__init__.py +164 -0
- agents/base_agent.py +743 -0
- agents/personality/character.py +119 -0
- agents/personality/character_manager.py +309 -0
- agents/personality/characters/rob.character.json +56 -0
- agents/personality/characters/trump.character.json +63 -0
- agents/personality/persona_render.py +78 -0
- agents/personality/persona_resolver.py +115 -0
- agents/prompt/__init__.py +58 -0
- agents/prompt/base_prompt.py +92 -0
- agents/prompt/system.py +417 -0
- agents/task/README_PATH_MANAGEMENT.md +141 -0
- agents/task/__init__.py +162 -0
- agents/task/agent/__init__.py +70 -0
- agents/task/agent/agent_state.py +408 -0
- agents/task/agent/async_delegation.py +274 -0
- agents/task/agent/autonomy_state.py +275 -0
- agents/task/agent/conversation.py +75 -0
- agents/task/agent/core/__init__.py +6 -0
- agents/task/agent/core/aux_metering.py +61 -0
- agents/task/agent/core/background_review.py +157 -0
- agents/task/agent/core/construction.py +1179 -0
- agents/task/agent/core/conversational_exit.py +49 -0
- agents/task/agent/core/correspondent_gate.py +227 -0
- agents/task/agent/core/curator.py +246 -0
- agents/task/agent/core/episodic_digest.py +103 -0
- agents/task/agent/core/error_recovery.py +480 -0
- agents/task/agent/core/history_io.py +257 -0
- agents/task/agent/core/llm_provisioning.py +287 -0
- agents/task/agent/core/llm_runner.py +547 -0
- agents/task/agent/core/logging_io.py +276 -0
- agents/task/agent/core/loop_detection.py +262 -0
- agents/task/agent/core/memory_prefetch.py +325 -0
- agents/task/agent/core/memory_writer.py +667 -0
- agents/task/agent/core/model_introspection.py +82 -0
- agents/task/agent/core/model_swap.py +177 -0
- agents/task/agent/core/next_action_internal.py +1331 -0
- agents/task/agent/core/output_validation.py +303 -0
- agents/task/agent/core/project_context.py +272 -0
- agents/task/agent/core/resources.py +93 -0
- agents/task/agent/core/result_processing.py +389 -0
- agents/task/agent/core/run_loop.py +661 -0
- agents/task/agent/core/safety_lifecycle.py +228 -0
- agents/task/agent/core/secret_guard.py +293 -0
- agents/task/agent/core/self_wake.py +280 -0
- agents/task/agent/core/session_metadata.py +104 -0
- agents/task/agent/core/step.py +781 -0
- agents/task/agent/core/step_execution.py +398 -0
- agents/task/agent/core/step_telemetry.py +222 -0
- agents/task/agent/core/test_aux_metering.py +50 -0
- agents/task/agent/core/test_billing_failover.py +68 -0
- agents/task/agent/core/test_fatal_error_classifier.py +38 -0
- agents/task/agent/core/test_judge_validation.py +275 -0
- agents/task/agent/core/test_model_swap.py +190 -0
- agents/task/agent/core/test_reflection_offload.py +54 -0
- agents/task/agent/core/turn_input.py +8 -0
- agents/task/agent/core/untrusted_wrap.py +103 -0
- agents/task/agent/core/user_ingress.py +228 -0
- agents/task/agent/hitl_manager.py +396 -0
- agents/task/agent/log_sanitize.py +36 -0
- agents/task/agent/message_manager/config.py +97 -0
- agents/task/agent/message_manager/service.py +758 -0
- agents/task/agent/message_manager/tests.py +305 -0
- agents/task/agent/message_manager/tool_call_builder.py +539 -0
- agents/task/agent/message_manager/tool_message_repair.py +364 -0
- agents/task/agent/message_manager/views.py +143 -0
- agents/task/agent/messages/__init__.py +8 -0
- agents/task/agent/messages/builders.py +309 -0
- agents/task/agent/messages/compactor.py +611 -0
- agents/task/agent/messages/context_references.py +271 -0
- agents/task/agent/messages/filters.py +333 -0
- agents/task/agent/messages/guidance.py +328 -0
- agents/task/agent/messages/persistence.py +448 -0
- agents/task/agent/messages/retrieval.py +506 -0
- agents/task/agent/messages/sqlite_persistence.py +85 -0
- agents/task/agent/messages/test_compaction_upgrade.py +349 -0
- agents/task/agent/messages/test_persistence_subdir_fix.py +28 -0
- agents/task/agent/messages/test_sqlite_persistence.py +54 -0
- agents/task/agent/messages/token_counter.py +532 -0
- agents/task/agent/orchestrator.py +776 -0
- agents/task/agent/profile_manager.py +105 -0
- agents/task/agent/profile_registry.py +173 -0
- agents/task/agent/prompts.py +1090 -0
- agents/task/agent/scenario_registry.py +226 -0
- agents/task/agent/service.py +509 -0
- agents/task/agent/session.py +984 -0
- agents/task/agent/skill_discovery.py +110 -0
- agents/task/agent/skill_frontmatter.py +94 -0
- agents/task/agent/skill_manager.py +1201 -0
- agents/task/agent/skill_store.py +627 -0
- agents/task/agent/skill_validation.py +56 -0
- agents/task/agent/skill_writer.py +492 -0
- agents/task/agent/sub_agent_manager.py +1137 -0
- agents/task/agent/test_session_disk_recovery.py +34 -0
- agents/task/agent/tests.py +513 -0
- agents/task/agent/tool_call_tracker.py +511 -0
- agents/task/agent/views.py +469 -0
- agents/task/config.py +432 -0
- agents/task/constants.py +1384 -0
- agents/task/flag_defaults.py +63 -0
- agents/task/goals/__init__.py +1 -0
- agents/task/goals/autonomy_marker.py +28 -0
- agents/task/goals/board.py +690 -0
- agents/task/goals/completion_judge.py +247 -0
- agents/task/goals/context.py +62 -0
- agents/task/goals/dispatcher.py +848 -0
- agents/task/goals/escalation.py +102 -0
- agents/task/goals/planner.py +114 -0
- agents/task/logging_config.py +155 -0
- agents/task/path.py +991 -0
- agents/task/robust_parse_config.py +400 -0
- agents/task/runtime/__init__.py +0 -0
- agents/task/runtime/run_as_session.py +130 -0
- agents/task/runtime_safety.py +308 -0
- agents/task/session/__init__.py +5 -0
- agents/task/session/browser_pool.py +130 -0
- agents/task/session/cleanup.py +612 -0
- agents/task/session/execution.py +397 -0
- agents/task/session/feed.py +200 -0
- agents/task/session/hitl_ingress.py +201 -0
- agents/task/session/hooks.py +83 -0
- agents/task/session/multi_agent.py +243 -0
- agents/task/session/workspace.py +91 -0
- agents/task/session_registry.py +91 -0
- agents/task/session_route.py +35 -0
- agents/task/sqlite_session_registry.py +261 -0
- agents/task/surface_config.py +185 -0
- agents/task/telemetry/__init__.py +58 -0
- agents/task/telemetry/event_log.py +180 -0
- agents/task/telemetry/formatters.py +642 -0
- agents/task/telemetry/manager.py +571 -0
- agents/task/telemetry/memory_events.py +66 -0
- agents/task/telemetry/self_events.py +53 -0
- agents/task/telemetry/sequence.py +160 -0
- agents/task/telemetry/service.py +1265 -0
- agents/task/telemetry/views.py +882 -0
- agents/task/templates.py +98 -0
- agents/task/test_aux_chain.py +151 -0
- agents/task/test_aux_router.py +41 -0
- agents/task/tests/test_parse_robustness.py +170 -0
- agents/task/tool_defaults.py +110 -0
- agents/task/utils.py +762 -0
- agents/task/utils_json.py +768 -0
- agents/task/utils_webview.py +86 -0
- agents/task/workspace_context.py +229 -0
- agents/task_agent_lite.py +2398 -0
- api/README.md +683 -0
- api/TASK_API_DOCS.md +151 -0
- api/__init__.py +0 -0
- api/a2a/__init__.py +37 -0
- api/a2a/agent_card.py +337 -0
- api/a2a/client.py +657 -0
- api/a2a/endpoints.py +375 -0
- api/a2a/models.py +268 -0
- api/a2a/streaming.py +419 -0
- api/a2a/task_handler.py +929 -0
- api/admin_endpoints.py +1584 -0
- api/app.py +923 -0
- api/auth_constants.py +28 -0
- api/auth_endpoints.py +402 -0
- api/auth_state.py +36 -0
- api/chat_via_task.py +42 -0
- api/conversation_manager.py +231 -0
- api/dependencies.py +186 -0
- api/eip8004_endpoints.py +452 -0
- api/hyperliquid_models.py +174 -0
- api/hyperliquid_routes.py +450 -0
- api/interfaces.py +207 -0
- api/jwt_middleware.py +83 -0
- api/kb/__init__.py +1 -0
- api/kb/endpoints.py +314 -0
- api/mcp_models.py +279 -0
- api/mcp_routes.py +438 -0
- api/middleware.py +526 -0
- api/models.py +176 -0
- api/openai_compat/__init__.py +0 -0
- api/openai_compat/model_map.py +25 -0
- api/openai_compat/models.py +59 -0
- api/openai_compat/router.py +140 -0
- api/payment_endpoints.py +444 -0
- api/payment_verification.py +138 -0
- api/polymarket_models.py +155 -0
- api/polymarket_routes.py +501 -0
- api/pricing_endpoints.py +89 -0
- api/session_routing.py +54 -0
- api/skill_endpoints.py +453 -0
- api/task_http_api.py +1856 -0
- api/webhooks.py +52 -0
- api/x402_endpoints.py +280 -0
- avatar/README.md +44 -0
- avatar/__init__.py +1 -0
- avatar/config/rob.json +7 -0
- avatar/mindprint.js +395 -0
- avatar/renders/rob.meta.json +20 -0
- avatar/renders/rob.png +0 -0
- avatar/studio.html +373 -0
- avatar/webview/avatar-live.js +44 -0
- cli/README.md +89 -0
- cli/__init__.py +0 -0
- cli/cli_surface.py +67 -0
- cli/commands/__init__.py +0 -0
- cli/commands/_bootstrap.py +49 -0
- cli/commands/_errors.py +53 -0
- cli/commands/chat.py +973 -0
- cli/commands/config.py +100 -0
- cli/commands/dashboard.py +103 -0
- cli/commands/doctor.py +222 -0
- cli/commands/email.py +174 -0
- cli/commands/gateway.py +346 -0
- cli/commands/goals.py +509 -0
- cli/commands/init.py +276 -0
- cli/commands/journey.py +30 -0
- cli/commands/kb.py +280 -0
- cli/commands/model.py +107 -0
- cli/commands/owner.py +431 -0
- cli/commands/pfp.py +232 -0
- cli/commands/run.py +414 -0
- cli/commands/serve.py +41 -0
- cli/commands/session.py +684 -0
- cli/commands/skill_install.py +786 -0
- cli/commands/skills.py +128 -0
- cli/commands/subagents.py +100 -0
- cli/commands/surface.py +81 -0
- cli/commands/telegram.py +185 -0
- cli/commands/todos.py +209 -0
- cli/commands/tools.py +102 -0
- cli/commands/update.py +316 -0
- cli/commands/whatsapp.py +175 -0
- cli/config_store.py +276 -0
- cli/gitignore.py +43 -0
- cli/inventory.py +46 -0
- cli/keys.py +101 -0
- cli/persona.py +17 -0
- cli/polyrob.py +137 -0
- cli/ui/__init__.py +64 -0
- cli/ui/activity.py +141 -0
- cli/ui/app.py +538 -0
- cli/ui/banner.py +233 -0
- cli/ui/blocks.py +534 -0
- cli/ui/bootstrap_notice.py +47 -0
- cli/ui/commands/__init__.py +41 -0
- cli/ui/commands/h_cron.py +64 -0
- cli/ui/commands/h_journey.py +164 -0
- cli/ui/commands/h_kb.py +121 -0
- cli/ui/commands/h_learn.py +100 -0
- cli/ui/commands/h_mcp.py +215 -0
- cli/ui/commands/h_self.py +113 -0
- cli/ui/commands/h_skills.py +314 -0
- cli/ui/commands/handlers.py +1672 -0
- cli/ui/commands/registry.py +426 -0
- cli/ui/dialog.py +425 -0
- cli/ui/event_registry.py +110 -0
- cli/ui/event_specs.py +45 -0
- cli/ui/events.py +433 -0
- cli/ui/identity.py +15 -0
- cli/ui/lifecycle.py +159 -0
- cli/ui/live_hooks.py +43 -0
- cli/ui/model_selector.py +532 -0
- cli/ui/persistent_loop.py +181 -0
- cli/ui/pick.py +113 -0
- cli/ui/plain_renderer.py +351 -0
- cli/ui/renderer.py +384 -0
- cli/ui/rich_renderer.py +533 -0
- cli/ui/secrets.py +115 -0
- cli/ui/state.py +376 -0
- cli/ui/statusbar.py +231 -0
- cli/ui/streaming.py +254 -0
- cli/ui/terminal_render.py +105 -0
- cli/ui/theme.py +132 -0
- cli/update/__init__.py +6 -0
- cli/update/context.py +121 -0
- cli/update/detect.py +176 -0
- cli/update/engine.py +95 -0
- cli/update/migrate_guarded.py +55 -0
- cli/update/process_guard.py +215 -0
- cli/update/runners.py +78 -0
- cli/update/snapshot.py +270 -0
- cli/update/versions.py +205 -0
- core/README.md +377 -0
- core/__init__.py +174 -0
- core/assets.py +87 -0
- core/async_bridge.py +76 -0
- core/autonomy_runtime.py +259 -0
- core/base_component.py +302 -0
- core/bootstrap.py +681 -0
- core/bot.py +310 -0
- core/config.py +833 -0
- core/constants.py +126 -0
- core/container.py +462 -0
- core/db_manifest.py +101 -0
- core/embedding.py +57 -0
- core/env.py +39 -0
- core/exceptions.py +287 -0
- core/flags.py +144 -0
- core/flags_catalog.py +345 -0
- core/home_migration.py +62 -0
- core/identity.py +118 -0
- core/initialization.py +1004 -0
- core/instance.py +537 -0
- core/interactive_gate.py +96 -0
- core/logging.py +436 -0
- core/owner_doc_writer.py +176 -0
- core/pairing.py +193 -0
- core/path_safety.py +20 -0
- core/paths.py +27 -0
- core/payment_config.py +21 -0
- core/permissions.py +322 -0
- core/runtime_config.py +96 -0
- core/runtime_paths.py +135 -0
- core/seams.py +35 -0
- core/secret_scan.py +25 -0
- core/secret_scrub.py +71 -0
- core/secrets.py +35 -0
- core/security_logging_filter.py +148 -0
- core/self_context_writer.py +333 -0
- core/self_evolution.py +294 -0
- core/session_context.py +47 -0
- core/sqlite_util.py +59 -0
- core/surfaces/__init__.py +16 -0
- core/surfaces/access.py +118 -0
- core/surfaces/binding.py +88 -0
- core/surfaces/bootstrap.py +78 -0
- core/surfaces/circuit.py +168 -0
- core/surfaces/continuity.py +77 -0
- core/surfaces/correspondents.py +228 -0
- core/surfaces/dispatcher.py +216 -0
- core/surfaces/envelopes.py +75 -0
- core/surfaces/gc.py +30 -0
- core/surfaces/idempotency.py +57 -0
- core/surfaces/inbound_webhook.py +124 -0
- core/surfaces/media.py +32 -0
- core/surfaces/message_router.py +91 -0
- core/surfaces/outbound_allowlist.py +80 -0
- core/surfaces/outbound_dispatcher.py +110 -0
- core/surfaces/outbound_mirror.py +37 -0
- core/surfaces/outbound_queue.py +107 -0
- core/surfaces/outbound_target.py +12 -0
- core/surfaces/owner_admin.py +29 -0
- core/surfaces/proactive.py +78 -0
- core/surfaces/progress.py +108 -0
- core/surfaces/rate_bucket.py +21 -0
- core/surfaces/registry.py +51 -0
- core/surfaces/rendering.py +53 -0
- core/surfaces/send_policy.py +14 -0
- core/surfaces/serialize.py +24 -0
- core/surfaces/session_chat_registry.py +112 -0
- core/surfaces/session_policy.py +60 -0
- core/surfaces/surface.py +288 -0
- core/surfaces/transcription.py +88 -0
- core/surfaces/voice_echo.py +26 -0
- core/surfaces/voice_guard.py +23 -0
- core/tickers.py +174 -0
- core/tool_catalog.py +192 -0
- core/version.py +75 -0
- core/wallet/__init__.py +5 -0
- core/wallet/agent_wallet.py +59 -0
- core/wallet/audit_sink.py +61 -0
- core/wallet/config.py +70 -0
- core/wallet/factory.py +87 -0
- core/wallet/policy.py +104 -0
- core/wallet/signer.py +51 -0
- cron/README.md +65 -0
- cron/__init__.py +0 -0
- cron/delivery.py +277 -0
- cron/digest.py +124 -0
- cron/jobs.py +207 -0
- cron/runner.py +297 -0
- cron/schedule.py +194 -0
- cron/scheduler.py +201 -0
- cron/service.py +57 -0
- cron/wake_gate.py +223 -0
- data/__init__.py +1 -0
- data/prompts/autov2_prompts.json +87 -0
- data/prompts/skills/browser-automation/SKILL.md +43 -0
- data/prompts/skills/coding-workflow/SKILL.md +36 -0
- data/prompts/skills/crypto-trading-safety/SKILL.md +53 -0
- data/prompts/skills/document-writing/SKILL.md +33 -0
- data/prompts/skills/email-comms/SKILL.md +33 -0
- data/prompts/skills/file-data-ops/SKILL.md +35 -0
- data/prompts/skills/hyperliquid-account-review/SKILL.md +48 -0
- data/prompts/skills/hyperliquid-market-data/SKILL.md +52 -0
- data/prompts/skills/hyperliquid-trading/SKILL.md +59 -0
- data/prompts/skills/lead-research/SKILL.md +86 -0
- data/prompts/skills/market-research-brief/SKILL.md +104 -0
- data/prompts/skills/person-analyzer/SKILL.md +124 -0
- data/prompts/skills/polymarket-market-research/SKILL.md +54 -0
- data/prompts/skills/polymarket-portfolio-review/SKILL.md +50 -0
- data/prompts/skills/polymarket-trading/SKILL.md +55 -0
- data/prompts/skills/presentation-creator/SKILL.md +36 -0
- data/prompts/skills/project-analyzer/SKILL.md +169 -0
- data/prompts/skills/rules.json +268 -0
- data/prompts/skills/secret-handling/SKILL.md +20 -0
- data/prompts/skills/skill-authoring/SKILL.md +31 -0
- data/prompts/skills/skill-security-review/SKILL.md +27 -0
- data/prompts/skills/social-discovery/SKILL.md +57 -0
- data/prompts/skills/task-planning/SKILL.md +33 -0
- data/prompts/skills/web-research/SKILL.md +39 -0
- data/prompts/skills/web-scraping/SKILL.md +73 -0
- data/prompts/skills/x-engagement/SKILL.md +69 -0
- data/prompts/system_prompts.json +4 -0
- data/subscription_channels.json +5 -0
- modules/README.md +503 -0
- modules/__init__.py +124 -0
- modules/auth/__init__.py +13 -0
- modules/auth/api_key_manager.py +157 -0
- modules/auth/identity_mapper.py +380 -0
- modules/auth/siwe_auth.py +273 -0
- modules/auth/tier_manager.py +173 -0
- modules/base_module.py +190 -0
- modules/credits/__init__.py +29 -0
- modules/credits/balance_manager.py +237 -0
- modules/credits/cost_utils.py +129 -0
- modules/credits/pricing.py +139 -0
- modules/credits/unified_ledger.py +148 -0
- modules/credits/usage_meter.py +310 -0
- modules/credits/usage_tracker.py +674 -0
- modules/database/__init__.py +33 -0
- modules/database/audit_log.py +322 -0
- modules/database/auth_tables.py +276 -0
- modules/database/connection.py +644 -0
- modules/database/connection_pool.py +305 -0
- modules/database/conversation_contexts.py +446 -0
- modules/database/database_manager.py +237 -0
- modules/database/hyperliquid.py +375 -0
- modules/database/polymarket.py +574 -0
- modules/database/user_mcp_servers.py +728 -0
- modules/database/user_profiles.py +562 -0
- modules/database/utils.py +107 -0
- modules/database/x402_tables.py +92 -0
- modules/eip8004/README.md +1069 -0
- modules/eip8004/__init__.py +65 -0
- modules/eip8004/contracts.py +498 -0
- modules/eip8004/models.py +271 -0
- modules/eip8004/registration.py +148 -0
- modules/eip8004/reputation.py +367 -0
- modules/eip8004/validation.py +277 -0
- modules/llm/__init__.py +97 -0
- modules/llm/adapters.py +963 -0
- modules/llm/anthropic_client.py +831 -0
- modules/llm/available_models.py +106 -0
- modules/llm/brain_scrubber.py +137 -0
- modules/llm/cache_hints.py +162 -0
- modules/llm/deepseek_client.py +562 -0
- modules/llm/gemini_client.py +1367 -0
- modules/llm/llm_client.py +1139 -0
- modules/llm/llm_client_registry.py +188 -0
- modules/llm/llm_factory.py +237 -0
- modules/llm/llm_manager.py +1036 -0
- modules/llm/messages.py +374 -0
- modules/llm/model_registry.py +1935 -0
- modules/llm/nvidia_client.py +125 -0
- modules/llm/openai_client.py +800 -0
- modules/llm/openrouter_client.py +969 -0
- modules/llm/profiles.py +178 -0
- modules/llm/test_anthropic_cache_capture.py +35 -0
- modules/llm/test_cached_pricing_derivation.py +24 -0
- modules/llm/think_scrubber.py +444 -0
- modules/llm/token_counter.py +268 -0
- modules/memory/__init__.py +35 -0
- modules/memory/backend_factory.py +83 -0
- modules/memory/cache_manager.py +186 -0
- modules/memory/episodic.py +108 -0
- modules/memory/local_vector_memory_provider.py +552 -0
- modules/memory/memory_manager.py +225 -0
- modules/memory/models.py +312 -0
- modules/memory/provider.py +210 -0
- modules/memory/registry.py +205 -0
- modules/memory/sqlite_memory_provider.py +767 -0
- modules/memory/task/__init__.py +52 -0
- modules/memory/task/compaction_manager.py +157 -0
- modules/memory/task/context_retriever.py +809 -0
- modules/memory/task/hierarchical_memory.py +1002 -0
- modules/memory/task/lexical_retriever.py +71 -0
- modules/memory/task/null_context_manager.py +213 -0
- modules/memory/task/phase_manager.py +625 -0
- modules/memory/task/reflection_service.py +157 -0
- modules/memory/task/semantic_retriever.py +218 -0
- modules/memory/task/task_context_manager.py +1165 -0
- modules/memory/task/test_forgetting_engages.py +24 -0
- modules/memory/task/test_reflection_llm.py +39 -0
- modules/memory/task/test_threat_scan.py +53 -0
- modules/memory/task/threat_scan.py +90 -0
- modules/memory/test_sqlite_memory_provider.py +106 -0
- modules/memory/user_profile_manager.py +527 -0
- modules/payments/__init__.py +11 -0
- modules/payments/deposit_monitor.py +478 -0
- modules/payments/price_oracle.py +70 -0
- modules/payments/treasury_sweeper.py +401 -0
- modules/payments/wallet_generator.py +145 -0
- modules/pfp/__init__.py +1 -0
- modules/pfp/config.py +92 -0
- modules/pfp/mesh.py +565 -0
- modules/pfp/push.py +69 -0
- modules/pfp/renderer.py +85 -0
- modules/pfp/store.py +82 -0
- modules/skills/__init__.py +1 -0
- modules/skills/skill_usage.py +248 -0
- modules/transcription/__init__.py +24 -0
- modules/transcription/base.py +20 -0
- modules/transcription/faster_whisper_transcriber.py +55 -0
- modules/x402/README.md +249 -0
- modules/x402/__init__.py +22 -0
- modules/x402/invoicing.py +416 -0
- modules/x402/middleware.py +364 -0
- modules/x402/settlement_watcher.py +145 -0
- modules/x402/x402_integration.py +344 -0
- polyrob-0.5.0.dist-info/METADATA +482 -0
- polyrob-0.5.0.dist-info/RECORD +745 -0
- polyrob-0.5.0.dist-info/WHEEL +5 -0
- polyrob-0.5.0.dist-info/entry_points.txt +2 -0
- polyrob-0.5.0.dist-info/licenses/LICENSE +21 -0
- polyrob-0.5.0.dist-info/top_level.txt +12 -0
- surfaces/README.md +70 -0
- surfaces/__init__.py +0 -0
- surfaces/email/__init__.py +0 -0
- surfaces/email/dedup.py +44 -0
- surfaces/email/harness.py +187 -0
- surfaces/email/inbound.py +159 -0
- surfaces/email/seed.py +60 -0
- surfaces/email/surface.py +105 -0
- surfaces/telegram/__init__.py +0 -0
- surfaces/telegram/dedup.py +83 -0
- surfaces/telegram/harness.py +886 -0
- surfaces/telegram/inbound.py +145 -0
- surfaces/telegram/interactive_tools.py +49 -0
- surfaces/telegram/markdown.py +347 -0
- surfaces/telegram/rate_limit.py +167 -0
- surfaces/telegram/surface.py +187 -0
- surfaces/telegram/voice.py +52 -0
- surfaces/whatsapp/__init__.py +0 -0
- surfaces/whatsapp/client.py +51 -0
- surfaces/whatsapp/harness.py +62 -0
- surfaces/whatsapp/inbound.py +132 -0
- surfaces/whatsapp/surface.py +64 -0
- surfaces/whatsapp/window.py +34 -0
- tools/README.md +578 -0
- tools/__init__.py +424 -0
- tools/alchemy/__init__.py +5 -0
- tools/alchemy/alchemy_tool.py +389 -0
- tools/anysite/__init__.py +17 -0
- tools/anysite/client.py +88 -0
- tools/anysite/tool.py +89 -0
- tools/base_tool.py +468 -0
- tools/browser/__init__.py +22 -0
- tools/browser/actions.py +118 -0
- tools/browser/browser.py +1457 -0
- tools/browser/browser_manager.py +690 -0
- tools/browser/context.py +1748 -0
- tools/browser/playwright_utils.py +137 -0
- tools/browser/views.py +56 -0
- tools/code_exec/SANDBOX_SECURITY.md +144 -0
- tools/code_exec/__init__.py +178 -0
- tools/code_exec/backend.py +73 -0
- tools/code_exec/backends/__init__.py +1 -0
- tools/code_exec/backends/docker.py +779 -0
- tools/code_exec/backends/local_subprocess.py +154 -0
- tools/code_exec/env_policy.py +45 -0
- tools/code_exec/result.py +42 -0
- tools/code_exec/sandbox_guard.py +59 -0
- tools/code_exec/tool.py +227 -0
- tools/coding/__init__.py +50 -0
- tools/coding/edit.py +107 -0
- tools/coding/search.py +113 -0
- tools/coding/tool.py +353 -0
- tools/collabland/__init__.py +5 -0
- tools/collabland/collabland_tool.py +471 -0
- tools/controller/__init__.py +0 -0
- tools/controller/_helpers.py +165 -0
- tools/controller/action_registration.py +1765 -0
- tools/controller/approval.py +244 -0
- tools/controller/approval_interactive.py +90 -0
- tools/controller/delegation.py +195 -0
- tools/controller/execution.py +797 -0
- tools/controller/execution_context.py +141 -0
- tools/controller/hooks.py +135 -0
- tools/controller/introspection.py +344 -0
- tools/controller/mcp_registrar.py +190 -0
- tools/controller/message_send.py +31 -0
- tools/controller/registry/__init__.py +4 -0
- tools/controller/registry/schema_generators.py +395 -0
- tools/controller/registry/schema_sanitizer.py +406 -0
- tools/controller/registry/service.py +1266 -0
- tools/controller/registry/views.py +151 -0
- tools/controller/service.py +409 -0
- tools/controller/tool_management.py +334 -0
- tools/controller/types.py +28 -0
- tools/controller/views.py +450 -0
- tools/cronjob_tools.py +166 -0
- tools/crypto_trade_gate.py +59 -0
- tools/descriptors.py +452 -0
- tools/dom/__init__.py +0 -0
- tools/dom/history_tree_processor/service.py +244 -0
- tools/dom/history_tree_processor/view.py +99 -0
- tools/dom/service.py +471 -0
- tools/dom/views.py +346 -0
- tools/email_tool.py +403 -0
- tools/exceptions.py +169 -0
- tools/filesystem.py +1038 -0
- tools/filesystem_docproc.py +331 -0
- tools/filesystem_pdf.py +755 -0
- tools/git/__init__.py +42 -0
- tools/git/tool.py +258 -0
- tools/github/__init__.py +33 -0
- tools/github/client.py +94 -0
- tools/github/tool.py +237 -0
- tools/goal_tools.py +309 -0
- tools/hyperliquid/__init__.py +56 -0
- tools/hyperliquid/models.py +233 -0
- tools/hyperliquid/service.py +1680 -0
- tools/knowledge_ingest.py +950 -0
- tools/mcp/README.md +535 -0
- tools/mcp/__init__.py +52 -0
- tools/mcp/catalog.py +115 -0
- tools/mcp/config.py +337 -0
- tools/mcp/mcp_tool.py +1415 -0
- tools/mcp/param_coercion.py +289 -0
- tools/mcp/protocol.py +1520 -0
- tools/mcp/rate_limit.py +50 -0
- tools/mcp/security.py +424 -0
- tools/mcp/self_install.py +111 -0
- tools/mcp/server_manager.py +829 -0
- tools/mcp/subscriptions.py +72 -0
- tools/mcp/user_mcp_service.py +899 -0
- tools/mcp/validation_tracker.py +89 -0
- tools/mcp/views.py +346 -0
- tools/oauth/__init__.py +17 -0
- tools/oauth/manager.py +75 -0
- tools/oauth/provider.py +69 -0
- tools/oauth/providers/__init__.py +1 -0
- tools/oauth/providers/generic_oauth2.py +96 -0
- tools/perplexity_tool.py +280 -0
- tools/polymarket/__init__.py +41 -0
- tools/polymarket/clob_adapter.py +76 -0
- tools/polymarket/models.py +182 -0
- tools/polymarket/service.py +2082 -0
- tools/self_env/__init__.py +61 -0
- tools/self_env/tool.py +274 -0
- tools/shell/__init__.py +80 -0
- tools/shell/backend_pool.py +118 -0
- tools/shell/discipline.py +62 -0
- tools/shell/executor.py +157 -0
- tools/shell/loopback_allow.py +87 -0
- tools/shell/process_registry.py +113 -0
- tools/shell/process_tool.py +131 -0
- tools/shell/state.py +129 -0
- tools/shell/tool.py +151 -0
- tools/task_tool.py +637 -0
- tools/twitter_tool.py +2086 -0
- tools/user_directory.py +179 -0
- tools/web_fetch/__init__.py +3 -0
- tools/web_fetch/fetcher.py +144 -0
- tools/web_fetch/render.py +44 -0
- tools/web_fetch/tool.py +60 -0
- tools/x402/__init__.py +60 -0
- tools/x402/client.py +47 -0
- tools/x402/invoice_tool.py +143 -0
- tools/x402/real_client.py +250 -0
- tools/x402/service.py +131 -0
- utils/README.md +498 -0
- utils/__init__.py +46 -0
- utils/auth_utils.py +114 -0
- utils/bounded_collections.py +162 -0
- utils/circuit_breaker.py +389 -0
- utils/gif_utils.py +435 -0
- utils/markdown_utils.py +291 -0
- utils/message_utils.py +147 -0
- utils/metrics.py +36 -0
- utils/path_validator.py +227 -0
- utils/rate_limit_manager.py +399 -0
- utils/result_size.py +296 -0
- utils/time_utils.py +206 -0
- utils/user_utils.py +188 -0
- webview/README.md +111 -0
- webview/RENAME_AND_ALIGN_HANDOFF.md +200 -0
- webview/__init__.py +8 -0
- webview/activity.py +636 -0
- webview/owner_auth.py +108 -0
- webview/pages.py +448 -0
- webview/repair_sessions.py +399 -0
- webview/server.py +4323 -0
- webview/server_launcher.py +112 -0
- webview/static/css/activity.css +89 -0
- webview/static/css/chat.css +1772 -0
- webview/static/css/components.css +1190 -0
- webview/static/css/config-panel.css +651 -0
- webview/static/css/pages/admin.css +766 -0
- webview/static/css/pages/profile.css +231 -0
- webview/static/css/pages/settings.css +297 -0
- webview/static/css/pages/signin.css +316 -0
- webview/static/css/style.css +4250 -0
- webview/static/css/variables.css +147 -0
- webview/static/css/workspace-fullwidth-fix.css +109 -0
- webview/static/img/favicon.ico +0 -0
- webview/static/js/activity.js +394 -0
- webview/static/js/admin/activity.js +186 -0
- webview/static/js/admin/dashboard.js +163 -0
- webview/static/js/admin/user_detail.js +400 -0
- webview/static/js/admin/users.js +174 -0
- webview/static/js/admin/utils.js +214 -0
- webview/static/js/chat.js +3178 -0
- webview/static/js/config-panel.js +522 -0
- webview/static/js/constants.js +20 -0
- webview/static/js/error-handler.js +226 -0
- webview/static/js/ethers.min.js +1 -0
- webview/static/js/event-filter.js +137 -0
- webview/static/js/event-store.js +351 -0
- webview/static/js/file-attachments.js +374 -0
- webview/static/js/file-loader.js +163 -0
- webview/static/js/index.js +103 -0
- webview/static/js/performance-utils.js +196 -0
- webview/static/js/profile.js +396 -0
- webview/static/js/screenshot.js +386 -0
- webview/static/js/session.js +1527 -0
- webview/static/js/settings.js +1288 -0
- webview/static/js/sidebar-data.js +766 -0
- webview/static/js/sidebar-toggle.js +296 -0
- webview/static/js/socket.io.min.js +7 -0
- webview/static/js/stats.js +355 -0
- webview/static/js/ui-utils.js +420 -0
- webview/static/js/workspace.js +966 -0
- webview/stats_service.py +613 -0
- webview/templates/__init__.py +1 -0
- webview/templates/__pycache__/__init__.cpython-311.pyc +0 -0
- webview/templates/activity.html +36 -0
- webview/templates/admin/activity.html +122 -0
- webview/templates/admin/dashboard.html +112 -0
- webview/templates/admin/user_detail.html +228 -0
- webview/templates/admin/users.html +105 -0
- webview/templates/autonomy.html +60 -0
- webview/templates/error.html +133 -0
- webview/templates/finance.html +90 -0
- webview/templates/identity.html +73 -0
- webview/templates/index.html +42 -0
- webview/templates/layout.html +125 -0
- webview/templates/memory.html +59 -0
- webview/templates/owner_login.html +15 -0
- webview/templates/profile.html +121 -0
- webview/templates/session.html +312 -0
- webview/templates/settings.html +534 -0
- webview/templates/sidebar.html +112 -0
- webview/templates/signin.html +213 -0
- webview/templates/status.html +14 -0
- webview/templates/system.html +45 -0
- webview/webgate.py +196 -0
|
@@ -0,0 +1,1935 @@
|
|
|
1
|
+
r"""
|
|
2
|
+
Model Registry for LLM Service - UPDATED DECEMBER 2025
|
|
3
|
+
|
|
4
|
+
This module centralizes all model configurations for currently available models.
|
|
5
|
+
Single source of truth for model information based on official docs.
|
|
6
|
+
|
|
7
|
+
Sources:
|
|
8
|
+
- OpenAI: https://platform.openai.com/docs/models
|
|
9
|
+
- Anthropic: https://docs.anthropic.com/en/docs/about-claude/models
|
|
10
|
+
- Google: https://ai.google.dev/gemini-api/docs/models
|
|
11
|
+
- DeepSeek: https://api-docs.deepseek.com/
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from dataclasses import dataclass
|
|
15
|
+
from typing import Dict, Optional, List, Tuple
|
|
16
|
+
from enum import Enum
|
|
17
|
+
import logging
|
|
18
|
+
import re
|
|
19
|
+
|
|
20
|
+
logger = logging.getLogger(__name__)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class ModelProvider(Enum):
|
|
24
|
+
"""Supported model providers"""
|
|
25
|
+
OPENAI = "openai"
|
|
26
|
+
ANTHROPIC = "anthropic"
|
|
27
|
+
GOOGLE = "google"
|
|
28
|
+
DEEPSEEK = "deepseek"
|
|
29
|
+
OPENROUTER = "openrouter"
|
|
30
|
+
NVIDIA = "nvidia"
|
|
31
|
+
CUSTOM = "custom"
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
# ---------------------------------------------------------------------------
|
|
35
|
+
# Canonical agent-facing provider strings (WS-2.3: ONE source of truth)
|
|
36
|
+
# ---------------------------------------------------------------------------
|
|
37
|
+
# The rest of the agent stack (Agent.provider_name, the streaming whitelist, the
|
|
38
|
+
# schema-generator registry, native-tools reconciliation) keys off PROVIDER
|
|
39
|
+
# STRINGS, not the ModelProvider enum. Those strings had drifted across ≥4
|
|
40
|
+
# hand-rolled maps — most painfully ``GOOGLE`` whose enum VALUE is ``"google"``
|
|
41
|
+
# but whose canonical agent-facing string is ``"gemini"`` (a mismatch that
|
|
42
|
+
# silently disabled Gemini streaming). This map is the single source of truth;
|
|
43
|
+
# every enum→string conversion MUST go through ``canonical_provider_name`` so a
|
|
44
|
+
# new provider is added in exactly one place and can never drift again.
|
|
45
|
+
PROVIDER_CANONICAL_NAMES: Dict[ModelProvider, str] = {
|
|
46
|
+
ModelProvider.OPENAI: "openai",
|
|
47
|
+
ModelProvider.ANTHROPIC: "anthropic",
|
|
48
|
+
ModelProvider.GOOGLE: "gemini", # NOT "google" — see note above
|
|
49
|
+
ModelProvider.DEEPSEEK: "deepseek",
|
|
50
|
+
ModelProvider.OPENROUTER: "openrouter",
|
|
51
|
+
ModelProvider.NVIDIA: "nvidia",
|
|
52
|
+
ModelProvider.CUSTOM: "custom",
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
#: Every canonical provider string the agent stack recognises.
|
|
56
|
+
CANONICAL_PROVIDER_NAMES = frozenset(PROVIDER_CANONICAL_NAMES.values())
|
|
57
|
+
|
|
58
|
+
#: Canonical providers that support response streaming (everything but custom).
|
|
59
|
+
STREAMING_PROVIDER_NAMES = CANONICAL_PROVIDER_NAMES - {"custom"}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def canonical_provider_name(provider: ModelProvider, default: str = "generic") -> str:
|
|
63
|
+
"""Map a ``ModelProvider`` enum to its canonical agent-facing string.
|
|
64
|
+
|
|
65
|
+
This is the ONLY sanctioned enum→string conversion. ``GOOGLE`` → ``"gemini"``
|
|
66
|
+
(not its enum value ``"google"``). Returns *default* for an unknown provider.
|
|
67
|
+
"""
|
|
68
|
+
return PROVIDER_CANONICAL_NAMES.get(provider, default)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
# Cache-READ price multipliers vs base input price. Reads are the discounted,
|
|
72
|
+
# high-volume slice: Anthropic/OpenAI/DeepSeek/OpenRouter ~0.1x, Gemini implicit ~0.25x
|
|
73
|
+
# (verified 2026-07-02: OpenAI GPT-5.x cached = 0.1x; Anthropic cache read = 0.1x;
|
|
74
|
+
# DeepSeek already 0.028 = 0.1x of 0.28). Only used to DERIVE cached_input_price when a
|
|
75
|
+
# model leaves it unset; inert on models that never report cache hits.
|
|
76
|
+
CACHE_READ_PRICE_MULTIPLIER = {
|
|
77
|
+
ModelProvider.ANTHROPIC: 0.1,
|
|
78
|
+
ModelProvider.OPENAI: 0.1,
|
|
79
|
+
ModelProvider.DEEPSEEK: 0.1,
|
|
80
|
+
ModelProvider.OPENROUTER: 0.1,
|
|
81
|
+
ModelProvider.NVIDIA: 0.1,
|
|
82
|
+
ModelProvider.GOOGLE: 0.25,
|
|
83
|
+
}
|
|
84
|
+
_DEFAULT_CACHE_READ_MULTIPLIER = 0.1
|
|
85
|
+
|
|
86
|
+
# Cache-WRITE (creation) price multipliers vs base input price. Only providers that
|
|
87
|
+
# charge a per-token surcharge to WRITE a cache entry appear here. Anthropic bills
|
|
88
|
+
# cache creation at 1.25x input (verified 2026-07-02, doc'd in anthropic_client). OpenAI
|
|
89
|
+
# implicit caching, DeepSeek, and Gemini implicit caching have NO per-token write charge,
|
|
90
|
+
# so they are absent → cache-creation tokens bill at plain input price (no surcharge).
|
|
91
|
+
CACHE_WRITE_PRICE_MULTIPLIER = {
|
|
92
|
+
ModelProvider.ANTHROPIC: 1.25,
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
@dataclass
|
|
97
|
+
class ModelPricing:
|
|
98
|
+
"""Model pricing information per 1M tokens"""
|
|
99
|
+
input_price: float # Price per 1M input tokens
|
|
100
|
+
cached_input_price: Optional[float] = None # Price for cached input (reads)
|
|
101
|
+
output_price: float = 0.0 # Price per 1M output tokens
|
|
102
|
+
# G3 (telemetry audit 2026-07-04): price to WRITE a cache entry (Anthropic 1.25x).
|
|
103
|
+
# None => no per-token write surcharge; cache-creation tokens bill at input_price.
|
|
104
|
+
cache_write_price: Optional[float] = None
|
|
105
|
+
batch_api_available: bool = False
|
|
106
|
+
currency: str = "USD"
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
@dataclass
|
|
110
|
+
class ModelCapabilities:
|
|
111
|
+
"""Model capabilities and features"""
|
|
112
|
+
supports_vision: bool = False # Default to False - only explicitly vision-capable models should be True
|
|
113
|
+
supports_function_calling: bool = True
|
|
114
|
+
supports_streaming: bool = True
|
|
115
|
+
supports_json_mode: bool = True
|
|
116
|
+
supports_system_messages: bool = True
|
|
117
|
+
supports_tools: bool = True
|
|
118
|
+
supports_audio: bool = False
|
|
119
|
+
supports_realtime: bool = False
|
|
120
|
+
supports_search: bool = False
|
|
121
|
+
supports_computer_use: bool = False
|
|
122
|
+
supports_thinking: bool = False
|
|
123
|
+
# UP-07: per-model reasoning budget/effort. None => provider/SDK default (current
|
|
124
|
+
# behavior). thinking_budget_tokens -> Anthropic thinking.budget_tokens / DeepSeek
|
|
125
|
+
# max_cot_tokens; reasoning_effort -> OpenAI ("minimal"|"low"|"medium"|"high"|"none").
|
|
126
|
+
thinking_budget_tokens: Optional[int] = None
|
|
127
|
+
reasoning_effort: Optional[str] = None
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
@dataclass
|
|
131
|
+
class ModelConfig:
|
|
132
|
+
"""Complete model configuration"""
|
|
133
|
+
name: str
|
|
134
|
+
provider: ModelProvider
|
|
135
|
+
context_window: int
|
|
136
|
+
max_completion_tokens: int
|
|
137
|
+
pricing: ModelPricing
|
|
138
|
+
capabilities: ModelCapabilities
|
|
139
|
+
chars_per_token: float = 4.0
|
|
140
|
+
aliases: List[str] = None
|
|
141
|
+
deprecated: bool = False
|
|
142
|
+
knowledge_cutoff: Optional[str] = None
|
|
143
|
+
# FIX (Jan 2026): Typical completion for dynamic reservation
|
|
144
|
+
# Most agent responses are 500-2000 tokens, not 64K
|
|
145
|
+
typical_completion_tokens: int = 4000 # Conservative typical usage
|
|
146
|
+
# P0.4: optional human-readable name override for UI surfaces (e.g. a model
|
|
147
|
+
# picker). None => derive a readable name from `name` (see
|
|
148
|
+
# `_derive_display_name`). Hand-author overrides for flagship models when
|
|
149
|
+
# the derived name reads badly.
|
|
150
|
+
display_name_override: Optional[str] = None
|
|
151
|
+
|
|
152
|
+
def __post_init__(self):
|
|
153
|
+
if self.aliases is None:
|
|
154
|
+
self.aliases = []
|
|
155
|
+
# Bill cache reads at the provider's discounted rate instead of $0. Preserves any
|
|
156
|
+
# explicit cached_input_price (DeepSeek + a few OpenRouter models). Safe: the cached
|
|
157
|
+
# slice is only charged when cached_tokens>0, i.e. when the provider reported a hit.
|
|
158
|
+
if self.pricing is not None and self.pricing.cached_input_price is None:
|
|
159
|
+
_mult = CACHE_READ_PRICE_MULTIPLIER.get(self.provider, _DEFAULT_CACHE_READ_MULTIPLIER)
|
|
160
|
+
self.pricing.cached_input_price = round(self.pricing.input_price * _mult, 6)
|
|
161
|
+
# G3: derive cache-WRITE price for providers that surcharge cache creation
|
|
162
|
+
# (Anthropic 1.25x). Absent providers keep None → billed at plain input price.
|
|
163
|
+
if self.pricing is not None and self.pricing.cache_write_price is None:
|
|
164
|
+
_wmult = CACHE_WRITE_PRICE_MULTIPLIER.get(self.provider)
|
|
165
|
+
if _wmult is not None:
|
|
166
|
+
self.pricing.cache_write_price = round(self.pricing.input_price * _wmult, 6)
|
|
167
|
+
|
|
168
|
+
@property
|
|
169
|
+
def display_name(self) -> str:
|
|
170
|
+
"""Human-readable name for UI surfaces (model picker, etc.).
|
|
171
|
+
|
|
172
|
+
Returns `display_name_override` if set, else a name derived from
|
|
173
|
+
`name` (vendor prefix stripped, title-cased, trailing date suffixed).
|
|
174
|
+
"""
|
|
175
|
+
if self.display_name_override:
|
|
176
|
+
return self.display_name_override
|
|
177
|
+
return _derive_display_name(self.name)
|
|
178
|
+
|
|
179
|
+
@property
|
|
180
|
+
def effective_completion_reserve(self) -> int:
|
|
181
|
+
"""Get effective completion token reservation.
|
|
182
|
+
|
|
183
|
+
FIX (Jan 2026): Dynamic reservation based on typical usage.
|
|
184
|
+
Reserves 2x typical for safety, capped at max.
|
|
185
|
+
This prevents wasting 47% of context on unused completion space.
|
|
186
|
+
|
|
187
|
+
Returns:
|
|
188
|
+
Token count to reserve for completion
|
|
189
|
+
"""
|
|
190
|
+
# Reserve 2x typical for safety buffer
|
|
191
|
+
dynamic_reserve = self.typical_completion_tokens * 2
|
|
192
|
+
# Cap at max_completion_tokens
|
|
193
|
+
return min(dynamic_reserve, self.max_completion_tokens)
|
|
194
|
+
|
|
195
|
+
@property
|
|
196
|
+
def safe_input_tokens(self) -> int:
|
|
197
|
+
"""Get safe input token limit (leaving room for completion).
|
|
198
|
+
|
|
199
|
+
FIX (Jan 2026): Now uses effective_completion_reserve instead of
|
|
200
|
+
max_completion_tokens for much better context utilization.
|
|
201
|
+
"""
|
|
202
|
+
return self.context_window - self.effective_completion_reserve
|
|
203
|
+
|
|
204
|
+
@property
|
|
205
|
+
def min_safe_tokens(self) -> int:
|
|
206
|
+
"""Get minimum safe token limit for this model"""
|
|
207
|
+
if self.context_window >= 500000: # 500k+ models
|
|
208
|
+
return 64000 # 64k minimum
|
|
209
|
+
elif self.context_window >= 100000: # 100k+ models
|
|
210
|
+
return 32000 # 32k minimum
|
|
211
|
+
elif self.context_window >= 32000: # 32k+ models
|
|
212
|
+
return 16000 # 16k minimum
|
|
213
|
+
elif self.context_window >= 16000: # 16k+ models
|
|
214
|
+
return 8000 # 8k minimum
|
|
215
|
+
else:
|
|
216
|
+
return 4000 # 4k minimum for smaller models
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
# Acronym-ish vendor/model tokens that should stay upper-cased rather than
|
|
220
|
+
# title-cased (e.g. "glm" -> "GLM", not "Glm"). Plain-word tokens (e.g.
|
|
221
|
+
# "kimi") fall through to `str.capitalize()` -> "Kimi", not "KIMI".
|
|
222
|
+
_DISPLAY_NAME_ACRONYMS = {"glm", "gpt"}
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
def _derive_display_name(name: str) -> str:
|
|
226
|
+
"""Derive a human-readable display name from a raw model id.
|
|
227
|
+
|
|
228
|
+
Strips a leading ``vendor/`` prefix, renders a trailing 4-digit date
|
|
229
|
+
segment (e.g. ``-0905``) as a parenthesized suffix, and title-cases the
|
|
230
|
+
remaining hyphen/underscore-separated words (with acronym handling for a
|
|
231
|
+
few well-known short tokens). Used as the fallback for
|
|
232
|
+
``ModelConfig.display_name`` when no ``display_name_override`` is set.
|
|
233
|
+
"""
|
|
234
|
+
base = name.split("/", 1)[-1] # drop vendor prefix, e.g. "moonshotai/"
|
|
235
|
+
match = re.search(r"-(\d{4})$", base) # trailing 4-digit date -> "(0905)"
|
|
236
|
+
suffix = f" ({match.group(1)})" if match else ""
|
|
237
|
+
if match:
|
|
238
|
+
base = base[: match.start()]
|
|
239
|
+
words = base.replace("_", "-").split("-")
|
|
240
|
+
|
|
241
|
+
def _cap(word: str) -> str:
|
|
242
|
+
if word.lower() in _DISPLAY_NAME_ACRONYMS or word.isdigit():
|
|
243
|
+
return word.upper()
|
|
244
|
+
return word.capitalize()
|
|
245
|
+
|
|
246
|
+
return " ".join(_cap(word) for word in words if word) + suffix
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
class ModelRegistry:
|
|
250
|
+
"""Central registry for all model configurations"""
|
|
251
|
+
|
|
252
|
+
def __init__(self):
|
|
253
|
+
self._models: Dict[str, ModelConfig] = {}
|
|
254
|
+
self._aliases: Dict[str, str] = {} # alias -> canonical name
|
|
255
|
+
self._initialize_models()
|
|
256
|
+
|
|
257
|
+
def _initialize_models(self):
|
|
258
|
+
"""Initialize all known models - CURRENT AS OF DEC 2025"""
|
|
259
|
+
|
|
260
|
+
# ========================================
|
|
261
|
+
# OPENAI MODELS
|
|
262
|
+
# ========================================
|
|
263
|
+
|
|
264
|
+
# GPT-5.1 Series (Released Nov 12, 2025)
|
|
265
|
+
# Source: https://openai.com/index/gpt-5-1-for-developers/
|
|
266
|
+
# Features: Adaptive thinking, apply_patch tool, shell tool
|
|
267
|
+
self._register_model(ModelConfig(
|
|
268
|
+
name="gpt-5.1",
|
|
269
|
+
provider=ModelProvider.OPENAI,
|
|
270
|
+
context_window=400000, # 400K tokens
|
|
271
|
+
max_completion_tokens=128000, # 128K output
|
|
272
|
+
pricing=ModelPricing(input_price=2.00, output_price=8.00),
|
|
273
|
+
capabilities=ModelCapabilities(
|
|
274
|
+
supports_vision=True,
|
|
275
|
+
supports_function_calling=True,
|
|
276
|
+
supports_thinking=True # Adaptive reasoning (can disable with reasoning_effort='none')
|
|
277
|
+
),
|
|
278
|
+
knowledge_cutoff="2025-11",
|
|
279
|
+
aliases=["gpt-5.1-chat-latest", "gpt-5-1", "gpt-5.1-thinking"]
|
|
280
|
+
))
|
|
281
|
+
|
|
282
|
+
self._register_model(ModelConfig(
|
|
283
|
+
name="gpt-5.1-mini",
|
|
284
|
+
provider=ModelProvider.OPENAI,
|
|
285
|
+
context_window=400000, # 400K tokens
|
|
286
|
+
max_completion_tokens=128000, # 128K output
|
|
287
|
+
pricing=ModelPricing(input_price=0.40, output_price=1.60),
|
|
288
|
+
capabilities=ModelCapabilities(
|
|
289
|
+
supports_vision=True,
|
|
290
|
+
supports_function_calling=True,
|
|
291
|
+
supports_thinking=True
|
|
292
|
+
),
|
|
293
|
+
knowledge_cutoff="2025-11",
|
|
294
|
+
aliases=["gpt-5.1-instant", "gpt-5-1-mini"]
|
|
295
|
+
))
|
|
296
|
+
|
|
297
|
+
# GPT-5.1 Codex Series (Specialized for coding)
|
|
298
|
+
self._register_model(ModelConfig(
|
|
299
|
+
name="gpt-5.1-codex",
|
|
300
|
+
provider=ModelProvider.OPENAI,
|
|
301
|
+
context_window=400000,
|
|
302
|
+
max_completion_tokens=128000,
|
|
303
|
+
pricing=ModelPricing(input_price=3.00, output_price=12.00),
|
|
304
|
+
capabilities=ModelCapabilities(
|
|
305
|
+
supports_vision=True,
|
|
306
|
+
supports_function_calling=True,
|
|
307
|
+
supports_thinking=True
|
|
308
|
+
),
|
|
309
|
+
knowledge_cutoff="2025-11",
|
|
310
|
+
aliases=["gpt-5-1-codex"]
|
|
311
|
+
))
|
|
312
|
+
|
|
313
|
+
self._register_model(ModelConfig(
|
|
314
|
+
name="gpt-5.1-codex-mini",
|
|
315
|
+
provider=ModelProvider.OPENAI,
|
|
316
|
+
context_window=400000,
|
|
317
|
+
max_completion_tokens=128000,
|
|
318
|
+
pricing=ModelPricing(input_price=0.60, output_price=2.40),
|
|
319
|
+
capabilities=ModelCapabilities(
|
|
320
|
+
supports_vision=True,
|
|
321
|
+
supports_function_calling=True,
|
|
322
|
+
supports_thinking=True
|
|
323
|
+
),
|
|
324
|
+
knowledge_cutoff="2025-11",
|
|
325
|
+
aliases=["gpt-5-1-codex-mini"]
|
|
326
|
+
))
|
|
327
|
+
|
|
328
|
+
self._register_model(ModelConfig(
|
|
329
|
+
name="gpt-5.1-codex-max",
|
|
330
|
+
provider=ModelProvider.OPENAI,
|
|
331
|
+
context_window=400000,
|
|
332
|
+
max_completion_tokens=128000,
|
|
333
|
+
pricing=ModelPricing(input_price=10.00, output_price=40.00),
|
|
334
|
+
capabilities=ModelCapabilities(
|
|
335
|
+
supports_vision=True,
|
|
336
|
+
supports_function_calling=True,
|
|
337
|
+
supports_thinking=True
|
|
338
|
+
),
|
|
339
|
+
knowledge_cutoff="2025-11",
|
|
340
|
+
aliases=["gpt-5-1-codex-max"]
|
|
341
|
+
))
|
|
342
|
+
|
|
343
|
+
# GPT-5 Series (Released Aug 7, 2025)
|
|
344
|
+
self._register_model(ModelConfig(
|
|
345
|
+
name="gpt-5",
|
|
346
|
+
provider=ModelProvider.OPENAI,
|
|
347
|
+
context_window=400000, # 400K tokens
|
|
348
|
+
max_completion_tokens=128000, # 128K output
|
|
349
|
+
pricing=ModelPricing(input_price=1.25, output_price=10.00),
|
|
350
|
+
capabilities=ModelCapabilities(
|
|
351
|
+
supports_vision=True,
|
|
352
|
+
supports_function_calling=True,
|
|
353
|
+
supports_thinking=True
|
|
354
|
+
),
|
|
355
|
+
knowledge_cutoff="2025-08",
|
|
356
|
+
aliases=["gpt-5-preview", "gpt-5-2025"]
|
|
357
|
+
))
|
|
358
|
+
|
|
359
|
+
self._register_model(ModelConfig(
|
|
360
|
+
name="gpt-5-pro",
|
|
361
|
+
provider=ModelProvider.OPENAI,
|
|
362
|
+
context_window=400000,
|
|
363
|
+
max_completion_tokens=128000,
|
|
364
|
+
pricing=ModelPricing(input_price=15.00, output_price=60.00),
|
|
365
|
+
capabilities=ModelCapabilities(
|
|
366
|
+
supports_vision=True,
|
|
367
|
+
supports_function_calling=True,
|
|
368
|
+
supports_thinking=True
|
|
369
|
+
),
|
|
370
|
+
knowledge_cutoff="2025-08"
|
|
371
|
+
))
|
|
372
|
+
|
|
373
|
+
self._register_model(ModelConfig(
|
|
374
|
+
name="gpt-5-mini",
|
|
375
|
+
provider=ModelProvider.OPENAI,
|
|
376
|
+
context_window=400000,
|
|
377
|
+
max_completion_tokens=128000,
|
|
378
|
+
pricing=ModelPricing(input_price=0.25, output_price=2.00),
|
|
379
|
+
capabilities=ModelCapabilities(
|
|
380
|
+
supports_vision=True,
|
|
381
|
+
supports_function_calling=True
|
|
382
|
+
),
|
|
383
|
+
knowledge_cutoff="2025-08"
|
|
384
|
+
))
|
|
385
|
+
|
|
386
|
+
self._register_model(ModelConfig(
|
|
387
|
+
name="gpt-5-nano",
|
|
388
|
+
provider=ModelProvider.OPENAI,
|
|
389
|
+
context_window=400000,
|
|
390
|
+
max_completion_tokens=128000,
|
|
391
|
+
pricing=ModelPricing(input_price=0.05, output_price=0.40),
|
|
392
|
+
capabilities=ModelCapabilities(
|
|
393
|
+
supports_vision=True,
|
|
394
|
+
supports_function_calling=True
|
|
395
|
+
),
|
|
396
|
+
knowledge_cutoff="2025-08"
|
|
397
|
+
))
|
|
398
|
+
|
|
399
|
+
# GPT-4.1 Series (Released Apr 2025) - 1M context!
|
|
400
|
+
# Source: https://openai.com/index/gpt-4-1/
|
|
401
|
+
self._register_model(ModelConfig(
|
|
402
|
+
name="gpt-4.1",
|
|
403
|
+
provider=ModelProvider.OPENAI,
|
|
404
|
+
context_window=1000000, # 1M tokens!
|
|
405
|
+
max_completion_tokens=32768, # 32K output
|
|
406
|
+
pricing=ModelPricing(input_price=2.00, output_price=8.00),
|
|
407
|
+
capabilities=ModelCapabilities(
|
|
408
|
+
supports_vision=True,
|
|
409
|
+
supports_function_calling=True
|
|
410
|
+
),
|
|
411
|
+
knowledge_cutoff="2025-04",
|
|
412
|
+
aliases=["gpt-4.1-2025-04-14", "gpt-4-1"]
|
|
413
|
+
))
|
|
414
|
+
|
|
415
|
+
self._register_model(ModelConfig(
|
|
416
|
+
name="gpt-4.1-mini",
|
|
417
|
+
provider=ModelProvider.OPENAI,
|
|
418
|
+
context_window=1000000, # 1M tokens
|
|
419
|
+
max_completion_tokens=32768,
|
|
420
|
+
pricing=ModelPricing(input_price=0.40, output_price=1.60),
|
|
421
|
+
capabilities=ModelCapabilities(
|
|
422
|
+
supports_vision=True,
|
|
423
|
+
supports_function_calling=True
|
|
424
|
+
),
|
|
425
|
+
knowledge_cutoff="2025-04",
|
|
426
|
+
aliases=["gpt-4.1-mini-2025-04-14", "gpt-4-1-mini"]
|
|
427
|
+
))
|
|
428
|
+
|
|
429
|
+
self._register_model(ModelConfig(
|
|
430
|
+
name="gpt-4.1-nano",
|
|
431
|
+
provider=ModelProvider.OPENAI,
|
|
432
|
+
context_window=1000000, # 1M tokens
|
|
433
|
+
max_completion_tokens=32768,
|
|
434
|
+
pricing=ModelPricing(input_price=0.10, output_price=0.40),
|
|
435
|
+
capabilities=ModelCapabilities(
|
|
436
|
+
supports_vision=True,
|
|
437
|
+
supports_function_calling=True
|
|
438
|
+
),
|
|
439
|
+
knowledge_cutoff="2025-04",
|
|
440
|
+
aliases=["gpt-4.1-nano-2025-04-14", "gpt-4-1-nano"]
|
|
441
|
+
))
|
|
442
|
+
|
|
443
|
+
# Reasoning Models (o-series)
|
|
444
|
+
# NOTE: O-series models are reasoning-focused and do NOT support vision
|
|
445
|
+
self._register_model(ModelConfig(
|
|
446
|
+
name="o3",
|
|
447
|
+
provider=ModelProvider.OPENAI,
|
|
448
|
+
context_window=262144,
|
|
449
|
+
max_completion_tokens=65536,
|
|
450
|
+
pricing=ModelPricing(input_price=10.00, output_price=40.00),
|
|
451
|
+
capabilities=ModelCapabilities(
|
|
452
|
+
supports_thinking=True,
|
|
453
|
+
supports_vision=False, # O-series doesn't support vision
|
|
454
|
+
supports_function_calling=False # O-series doesn't support tools
|
|
455
|
+
),
|
|
456
|
+
knowledge_cutoff="2025-10",
|
|
457
|
+
aliases=["o3-2025"]
|
|
458
|
+
))
|
|
459
|
+
|
|
460
|
+
self._register_model(ModelConfig(
|
|
461
|
+
name="o4-mini",
|
|
462
|
+
provider=ModelProvider.OPENAI,
|
|
463
|
+
context_window=262144,
|
|
464
|
+
max_completion_tokens=32768,
|
|
465
|
+
pricing=ModelPricing(input_price=1.00, output_price=4.00),
|
|
466
|
+
capabilities=ModelCapabilities(
|
|
467
|
+
supports_thinking=True,
|
|
468
|
+
supports_vision=False, # O-series doesn't support vision
|
|
469
|
+
supports_function_calling=False # O-series doesn't support tools
|
|
470
|
+
),
|
|
471
|
+
knowledge_cutoff="2025-10"
|
|
472
|
+
))
|
|
473
|
+
|
|
474
|
+
# GPT-4o - DEPRECATED (Oct 2025)
|
|
475
|
+
self._register_model(ModelConfig(
|
|
476
|
+
name="gpt-4o",
|
|
477
|
+
provider=ModelProvider.OPENAI,
|
|
478
|
+
context_window=128000,
|
|
479
|
+
max_completion_tokens=16384,
|
|
480
|
+
pricing=ModelPricing(input_price=2.50, output_price=10.00),
|
|
481
|
+
capabilities=ModelCapabilities(
|
|
482
|
+
supports_vision=True,
|
|
483
|
+
supports_function_calling=True,
|
|
484
|
+
supports_audio=True
|
|
485
|
+
),
|
|
486
|
+
knowledge_cutoff="2024-10",
|
|
487
|
+
aliases=["gpt-4o-2024-11-20", "gpt-4o-latest"],
|
|
488
|
+
deprecated=True
|
|
489
|
+
))
|
|
490
|
+
|
|
491
|
+
# ========================================
|
|
492
|
+
# ANTHROPIC MODELS (December 2024)
|
|
493
|
+
# ========================================
|
|
494
|
+
|
|
495
|
+
# Claude 4.5 Series - Latest (Nov 2025)
|
|
496
|
+
# Source: https://docs.anthropic.com/en/docs/about-claude/models
|
|
497
|
+
# DEPRECATED ALIASES: Claude 3.x models are deprecated but mapped here for backward compatibility
|
|
498
|
+
self._register_model(ModelConfig(
|
|
499
|
+
name="claude-sonnet-4-5",
|
|
500
|
+
provider=ModelProvider.ANTHROPIC,
|
|
501
|
+
context_window=200000, # 1M with beta header
|
|
502
|
+
max_completion_tokens=64000, # FIXED: Anthropic max is 64000, not 65536
|
|
503
|
+
pricing=ModelPricing(input_price=3.00, output_price=15.00),
|
|
504
|
+
capabilities=ModelCapabilities(
|
|
505
|
+
supports_thinking=True, # Extended thinking supported
|
|
506
|
+
thinking_budget_tokens=64000, # UP-07 (was AnthropicClient.EXTENDED_THINKING_MODELS)
|
|
507
|
+
),
|
|
508
|
+
chars_per_token=5.0,
|
|
509
|
+
knowledge_cutoff="2025-01",
|
|
510
|
+
aliases=[
|
|
511
|
+
# Current aliases
|
|
512
|
+
"claude-sonnet-4.5", "claude-4.5-sonnet", "claude-sonnet-4", "claude-sonnet-4-5-20250929",
|
|
513
|
+
# DEPRECATED Claude 3.5 Sonnet aliases (maps to 4.5 for backward compat)
|
|
514
|
+
"claude-3-5-sonnet-20241022", "claude-3-5-sonnet-20240620",
|
|
515
|
+
"claude-3-5-sonnet-latest", "claude-3-5-sonnet", "claude-3.5-sonnet",
|
|
516
|
+
"claude-3-sonnet-20240229", "claude-3-sonnet"
|
|
517
|
+
]
|
|
518
|
+
))
|
|
519
|
+
|
|
520
|
+
self._register_model(ModelConfig(
|
|
521
|
+
name="claude-haiku-4-5",
|
|
522
|
+
provider=ModelProvider.ANTHROPIC,
|
|
523
|
+
context_window=200000,
|
|
524
|
+
max_completion_tokens=64000, # FIXED: Anthropic max is 64000, not 65536
|
|
525
|
+
pricing=ModelPricing(input_price=1.00, output_price=5.00),
|
|
526
|
+
capabilities=ModelCapabilities(
|
|
527
|
+
supports_thinking=True, # Extended thinking supported
|
|
528
|
+
thinking_budget_tokens=64000, # UP-07 (was AnthropicClient.EXTENDED_THINKING_MODELS)
|
|
529
|
+
),
|
|
530
|
+
chars_per_token=5.0,
|
|
531
|
+
knowledge_cutoff="2025-02",
|
|
532
|
+
aliases=[
|
|
533
|
+
# Current aliases
|
|
534
|
+
"claude-haiku-4.5", "claude-4.5-haiku", "claude-haiku-4-5-20251001",
|
|
535
|
+
# DEPRECATED Claude 3.5 Haiku aliases (maps to 4.5 for backward compat)
|
|
536
|
+
"claude-3-5-haiku-20241022", "claude-3-5-haiku-latest", "claude-3-5-haiku",
|
|
537
|
+
"claude-3.5-haiku", "claude-3-haiku-20240307", "claude-3-haiku"
|
|
538
|
+
]
|
|
539
|
+
))
|
|
540
|
+
|
|
541
|
+
# Claude Opus 4.5 - NEW Premium model (Nov 2025)
|
|
542
|
+
# Maximum intelligence with practical performance
|
|
543
|
+
self._register_model(ModelConfig(
|
|
544
|
+
name="claude-opus-4-5",
|
|
545
|
+
provider=ModelProvider.ANTHROPIC,
|
|
546
|
+
context_window=200000,
|
|
547
|
+
max_completion_tokens=64000, # FIXED: Anthropic max is 64000, not 65536
|
|
548
|
+
pricing=ModelPricing(input_price=5.00, output_price=25.00),
|
|
549
|
+
capabilities=ModelCapabilities(
|
|
550
|
+
supports_thinking=True, # Extended thinking supported
|
|
551
|
+
thinking_budget_tokens=64000, # UP-07 (was AnthropicClient.EXTENDED_THINKING_MODELS)
|
|
552
|
+
),
|
|
553
|
+
chars_per_token=5.0,
|
|
554
|
+
knowledge_cutoff="2025-03",
|
|
555
|
+
aliases=[
|
|
556
|
+
# Current aliases
|
|
557
|
+
"claude-opus-4.5", "claude-4.5-opus", "claude-opus-4-5-20251101",
|
|
558
|
+
# DEPRECATED Claude 3 Opus aliases (maps to 4.5 for backward compat)
|
|
559
|
+
"claude-3-opus-20240229", "claude-3-opus", "claude-3.0-opus"
|
|
560
|
+
]
|
|
561
|
+
))
|
|
562
|
+
|
|
563
|
+
# Claude Opus 4.1 - Specialized reasoning (legacy)
|
|
564
|
+
self._register_model(ModelConfig(
|
|
565
|
+
name="claude-opus-4-1",
|
|
566
|
+
provider=ModelProvider.ANTHROPIC,
|
|
567
|
+
context_window=200000,
|
|
568
|
+
max_completion_tokens=32768, # 32K output
|
|
569
|
+
pricing=ModelPricing(input_price=15.00, output_price=75.00),
|
|
570
|
+
capabilities=ModelCapabilities(
|
|
571
|
+
supports_thinking=True,
|
|
572
|
+
thinking_budget_tokens=32768, # UP-07 (was AnthropicClient.EXTENDED_THINKING_MODELS)
|
|
573
|
+
),
|
|
574
|
+
chars_per_token=5.0,
|
|
575
|
+
knowledge_cutoff="2025-01",
|
|
576
|
+
aliases=["claude-4-opus", "claude-opus-4", "claude-opus-4.1", "claude-opus-4-1-20250805"]
|
|
577
|
+
))
|
|
578
|
+
|
|
579
|
+
# Claude 3.x Series - REMOVED (deprecated Oct 2025)
|
|
580
|
+
# Deprecated model names are now aliases to Claude 4.5 models above
|
|
581
|
+
|
|
582
|
+
# ========================================
|
|
583
|
+
# GOOGLE GEMINI MODELS (December 2025)
|
|
584
|
+
# Source: https://ai.google.dev/gemini-api/docs/models
|
|
585
|
+
# Official model codes from Google API documentation
|
|
586
|
+
# ========================================
|
|
587
|
+
|
|
588
|
+
# ----------------------------------------
|
|
589
|
+
# GEMINI 3 SERIES - PREVIEW (Nov 2025)
|
|
590
|
+
# ----------------------------------------
|
|
591
|
+
|
|
592
|
+
# Gemini 3 Pro Preview - Best multimodal & agentic model
|
|
593
|
+
# API Code: gemini-3-pro-preview
|
|
594
|
+
# Supports: Text, Image, Video, Audio, PDF input -> Text output
|
|
595
|
+
self._register_model(ModelConfig(
|
|
596
|
+
name="gemini-3-pro-preview",
|
|
597
|
+
provider=ModelProvider.GOOGLE,
|
|
598
|
+
context_window=1048576, # 1M tokens
|
|
599
|
+
max_completion_tokens=65536, # 65K output
|
|
600
|
+
pricing=ModelPricing(input_price=2.50, output_price=10.00),
|
|
601
|
+
capabilities=ModelCapabilities(
|
|
602
|
+
supports_vision=True, # Multimodal: Image, Video, Audio, PDF
|
|
603
|
+
supports_thinking=True, # Thinking supported
|
|
604
|
+
supports_function_calling=True, # Function calling supported
|
|
605
|
+
supports_streaming=True,
|
|
606
|
+
supports_json_mode=True, # Structured outputs
|
|
607
|
+
supports_tools=True
|
|
608
|
+
),
|
|
609
|
+
knowledge_cutoff="2025-01", # Per docs: January 2025
|
|
610
|
+
aliases=["gemini-3-pro", "gemini-3", "gemini-3-preview"]
|
|
611
|
+
))
|
|
612
|
+
|
|
613
|
+
# Gemini 3 Pro Image Preview - Image generation model
|
|
614
|
+
# API Code: gemini-3-pro-image-preview
|
|
615
|
+
# Supports: Image and Text input -> Image and Text output
|
|
616
|
+
# NOTE: Does NOT support function calling!
|
|
617
|
+
self._register_model(ModelConfig(
|
|
618
|
+
name="gemini-3-pro-image-preview",
|
|
619
|
+
provider=ModelProvider.GOOGLE,
|
|
620
|
+
context_window=65536, # 65K input
|
|
621
|
+
max_completion_tokens=32768, # 32K output
|
|
622
|
+
pricing=ModelPricing(input_price=2.50, output_price=10.00),
|
|
623
|
+
capabilities=ModelCapabilities(
|
|
624
|
+
supports_vision=True, # Image input
|
|
625
|
+
supports_thinking=True, # Thinking supported
|
|
626
|
+
supports_function_calling=False, # NOT supported per docs!
|
|
627
|
+
supports_streaming=True,
|
|
628
|
+
supports_json_mode=True, # Structured outputs
|
|
629
|
+
supports_tools=False # NOT supported
|
|
630
|
+
),
|
|
631
|
+
knowledge_cutoff="2025-01",
|
|
632
|
+
aliases=["gemini-3-pro-image", "gemini-3-image"]
|
|
633
|
+
))
|
|
634
|
+
|
|
635
|
+
# ----------------------------------------
|
|
636
|
+
# GEMINI 2.5 SERIES - STABLE (June-Sept 2025)
|
|
637
|
+
# ----------------------------------------
|
|
638
|
+
|
|
639
|
+
# Gemini 2.5 Flash - Best price-performance model (STABLE)
|
|
640
|
+
# API Code: gemini-2.5-flash
|
|
641
|
+
# Fast, intelligent, large-scale processing
|
|
642
|
+
self._register_model(ModelConfig(
|
|
643
|
+
name="gemini-2.5-flash",
|
|
644
|
+
provider=ModelProvider.GOOGLE,
|
|
645
|
+
context_window=1048576, # 1M tokens
|
|
646
|
+
max_completion_tokens=65536, # 65K output
|
|
647
|
+
pricing=ModelPricing(input_price=0.075, output_price=0.30), # Flash pricing
|
|
648
|
+
capabilities=ModelCapabilities(
|
|
649
|
+
supports_vision=True, # Text, images, video, audio
|
|
650
|
+
supports_thinking=True, # Thinking supported
|
|
651
|
+
supports_function_calling=True,
|
|
652
|
+
supports_streaming=True,
|
|
653
|
+
supports_json_mode=True,
|
|
654
|
+
supports_tools=True
|
|
655
|
+
),
|
|
656
|
+
knowledge_cutoff="2025-01",
|
|
657
|
+
aliases=["gemini-2.5-flash-stable", "gemini-flash-latest"]
|
|
658
|
+
))
|
|
659
|
+
|
|
660
|
+
# Gemini 2.5 Flash Preview
|
|
661
|
+
# API Code: gemini-2.5-flash-preview-09-2025
|
|
662
|
+
self._register_model(ModelConfig(
|
|
663
|
+
name="gemini-2.5-flash-preview-09-2025",
|
|
664
|
+
provider=ModelProvider.GOOGLE,
|
|
665
|
+
context_window=1048576, # 1M tokens
|
|
666
|
+
max_completion_tokens=65536, # 65K output
|
|
667
|
+
pricing=ModelPricing(input_price=0.075, output_price=0.30),
|
|
668
|
+
capabilities=ModelCapabilities(
|
|
669
|
+
supports_vision=True,
|
|
670
|
+
supports_thinking=True,
|
|
671
|
+
supports_function_calling=True,
|
|
672
|
+
supports_streaming=True,
|
|
673
|
+
supports_json_mode=True,
|
|
674
|
+
supports_tools=True
|
|
675
|
+
),
|
|
676
|
+
knowledge_cutoff="2025-01",
|
|
677
|
+
aliases=["gemini-2.5-flash-preview"]
|
|
678
|
+
))
|
|
679
|
+
|
|
680
|
+
# ----------------------------------------
|
|
681
|
+
# GEMINI 2.0 SERIES - STABLE (Feb 2025)
|
|
682
|
+
# ----------------------------------------
|
|
683
|
+
|
|
684
|
+
# Gemini 2.0 Flash - Fast multimodal model
|
|
685
|
+
# API Code: gemini-2.0-flash
|
|
686
|
+
self._register_model(ModelConfig(
|
|
687
|
+
name="gemini-2.0-flash",
|
|
688
|
+
provider=ModelProvider.GOOGLE,
|
|
689
|
+
context_window=1048576, # 1M tokens
|
|
690
|
+
max_completion_tokens=8192, # 8K output
|
|
691
|
+
pricing=ModelPricing(input_price=0.10, output_price=0.40),
|
|
692
|
+
capabilities=ModelCapabilities(
|
|
693
|
+
supports_vision=True, # Audio, images, video, text
|
|
694
|
+
supports_thinking=False, # Thinking is "Experimental" per docs
|
|
695
|
+
supports_function_calling=True,
|
|
696
|
+
supports_streaming=True,
|
|
697
|
+
supports_json_mode=True,
|
|
698
|
+
supports_tools=True,
|
|
699
|
+
supports_realtime=True # Live API supported
|
|
700
|
+
),
|
|
701
|
+
knowledge_cutoff="2024-08",
|
|
702
|
+
aliases=["gemini-2.0-flash-001", "gemini-2.0-flash-exp"]
|
|
703
|
+
))
|
|
704
|
+
|
|
705
|
+
# Gemini 2.0 Flash-Lite - Cost-efficient model
|
|
706
|
+
# API Code: gemini-2.0-flash-lite
|
|
707
|
+
self._register_model(ModelConfig(
|
|
708
|
+
name="gemini-2.0-flash-lite",
|
|
709
|
+
provider=ModelProvider.GOOGLE,
|
|
710
|
+
context_window=1048576, # 1M tokens
|
|
711
|
+
max_completion_tokens=8192, # 8K output
|
|
712
|
+
pricing=ModelPricing(input_price=0.075, output_price=0.30),
|
|
713
|
+
capabilities=ModelCapabilities(
|
|
714
|
+
supports_vision=True, # Audio, images, video, text
|
|
715
|
+
supports_thinking=False, # NOT supported per docs
|
|
716
|
+
supports_function_calling=True,
|
|
717
|
+
supports_streaming=True,
|
|
718
|
+
supports_json_mode=True, # Structured outputs
|
|
719
|
+
supports_tools=False # NOT supported per docs
|
|
720
|
+
),
|
|
721
|
+
knowledge_cutoff="2024-08",
|
|
722
|
+
aliases=["gemini-2.0-flash-lite-001"]
|
|
723
|
+
))
|
|
724
|
+
|
|
725
|
+
# ----------------------------------------
|
|
726
|
+
# LEGACY - Gemini 2.5 Pro (for backwards compat)
|
|
727
|
+
# ----------------------------------------
|
|
728
|
+
# Note: Gemini 2.5 Pro is NOT in current docs, may be deprecated
|
|
729
|
+
# Keeping for backwards compatibility with existing sessions
|
|
730
|
+
self._register_model(ModelConfig(
|
|
731
|
+
name="gemini-2.5-pro",
|
|
732
|
+
provider=ModelProvider.GOOGLE,
|
|
733
|
+
context_window=1048576, # 1M tokens
|
|
734
|
+
max_completion_tokens=65536, # 65K output
|
|
735
|
+
pricing=ModelPricing(input_price=1.25, output_price=5.00),
|
|
736
|
+
capabilities=ModelCapabilities(
|
|
737
|
+
supports_vision=True,
|
|
738
|
+
supports_thinking=True,
|
|
739
|
+
supports_function_calling=True,
|
|
740
|
+
supports_streaming=True,
|
|
741
|
+
supports_json_mode=True,
|
|
742
|
+
supports_tools=True
|
|
743
|
+
),
|
|
744
|
+
knowledge_cutoff="2025-01",
|
|
745
|
+
aliases=["gemini-2.5-pro-exp", "gemini-2.5-pro-preview-03-25", "gemini-pro"]
|
|
746
|
+
))
|
|
747
|
+
|
|
748
|
+
# ========================================
|
|
749
|
+
# DEEPSEEK MODELS (December 2025)
|
|
750
|
+
# Source: https://api-docs.deepseek.com/quick_start/pricing
|
|
751
|
+
# ========================================
|
|
752
|
+
|
|
753
|
+
# DeepSeek-V3.2 Chat - Non-thinking mode (Released Dec 1, 2025)
|
|
754
|
+
# 671B total params, 37B active per token (MoE architecture)
|
|
755
|
+
self._register_model(ModelConfig(
|
|
756
|
+
name="deepseek-chat",
|
|
757
|
+
provider=ModelProvider.DEEPSEEK,
|
|
758
|
+
context_window=128000, # 128K context with DSA (DeepSeek Sparse Attention)
|
|
759
|
+
max_completion_tokens=8192, # 4K default, 8K max
|
|
760
|
+
pricing=ModelPricing(
|
|
761
|
+
input_price=0.28, # $0.28/M tokens (cache miss)
|
|
762
|
+
cached_input_price=0.028, # $0.028/M tokens (cache hit)
|
|
763
|
+
output_price=0.42 # $0.42/M tokens
|
|
764
|
+
),
|
|
765
|
+
capabilities=ModelCapabilities(
|
|
766
|
+
supports_function_calling=True,
|
|
767
|
+
supports_tools=True,
|
|
768
|
+
supports_json_mode=True,
|
|
769
|
+
supports_vision=False,
|
|
770
|
+
supports_streaming=True
|
|
771
|
+
),
|
|
772
|
+
knowledge_cutoff="2025-12",
|
|
773
|
+
aliases=["deepseek-v3.2", "deepseek-v3", "deepseek-chat-v3.2"]
|
|
774
|
+
))
|
|
775
|
+
|
|
776
|
+
# DeepSeek-V3.2 Reasoner - Thinking mode (Released Dec 1, 2025)
|
|
777
|
+
# Same architecture as chat but with extended thinking
|
|
778
|
+
self._register_model(ModelConfig(
|
|
779
|
+
name="deepseek-reasoner",
|
|
780
|
+
provider=ModelProvider.DEEPSEEK,
|
|
781
|
+
context_window=128000, # 128K context
|
|
782
|
+
max_completion_tokens=64000, # 32K default, 64K max
|
|
783
|
+
pricing=ModelPricing(
|
|
784
|
+
input_price=0.28, # $0.28/M tokens (cache miss)
|
|
785
|
+
cached_input_price=0.028, # $0.028/M tokens (cache hit)
|
|
786
|
+
output_price=0.42 # $0.42/M tokens
|
|
787
|
+
),
|
|
788
|
+
capabilities=ModelCapabilities(
|
|
789
|
+
supports_thinking=True,
|
|
790
|
+
thinking_budget_tokens=32000, # UP-07: was deepseek_client DEFAULT_MAX_COT_TOKENS
|
|
791
|
+
supports_function_calling=True, # V3.2 reasoner now supports tools
|
|
792
|
+
supports_tools=True,
|
|
793
|
+
supports_json_mode=True,
|
|
794
|
+
supports_vision=False,
|
|
795
|
+
supports_streaming=True
|
|
796
|
+
),
|
|
797
|
+
knowledge_cutoff="2025-12",
|
|
798
|
+
aliases=["deepseek-v3.2-reasoner", "deepseek-r1", "deepseek-thinking"]
|
|
799
|
+
))
|
|
800
|
+
|
|
801
|
+
# DeepSeek-V3.2-Speciale - Extended reasoning (Temporary until Dec 15, 2025)
|
|
802
|
+
# Enhanced thinking mode with 128K output
|
|
803
|
+
self._register_model(ModelConfig(
|
|
804
|
+
name="deepseek-speciale",
|
|
805
|
+
provider=ModelProvider.DEEPSEEK,
|
|
806
|
+
context_window=128000, # 128K context
|
|
807
|
+
max_completion_tokens=128000, # 128K output!
|
|
808
|
+
pricing=ModelPricing(
|
|
809
|
+
input_price=0.28,
|
|
810
|
+
cached_input_price=0.028,
|
|
811
|
+
output_price=0.42
|
|
812
|
+
),
|
|
813
|
+
capabilities=ModelCapabilities(
|
|
814
|
+
supports_thinking=True,
|
|
815
|
+
supports_function_calling=False, # Thinking mode only
|
|
816
|
+
supports_tools=False,
|
|
817
|
+
supports_vision=False # DeepSeek doesn't support vision
|
|
818
|
+
),
|
|
819
|
+
knowledge_cutoff="2025-12",
|
|
820
|
+
aliases=["deepseek-v3.2-speciale"]
|
|
821
|
+
))
|
|
822
|
+
|
|
823
|
+
# ========================================
|
|
824
|
+
# OPENROUTER MODELS (December 2025)
|
|
825
|
+
# Access via https://openrouter.ai/models
|
|
826
|
+
# Pricing: $ per million tokens
|
|
827
|
+
# ========================================
|
|
828
|
+
|
|
829
|
+
# ----------------------------------------
|
|
830
|
+
# Z.AI GLM MODELS (Zhipu AI via OpenRouter)
|
|
831
|
+
# https://openrouter.ai/provider/z-ai
|
|
832
|
+
# ----------------------------------------
|
|
833
|
+
|
|
834
|
+
# GLM-5.2 - current Z.AI flagship on OpenRouter (default for `--provider
|
|
835
|
+
# openrouter`). 1M context, native tools + reasoning + structured outputs,
|
|
836
|
+
# text-only. OpenAI-compatible via OpenRouter (no client change needed).
|
|
837
|
+
# Specs/pricing verified against the live OpenRouter models API (2026-06-18).
|
|
838
|
+
self._register_model(ModelConfig(
|
|
839
|
+
name="z-ai/glm-5.2",
|
|
840
|
+
provider=ModelProvider.OPENROUTER,
|
|
841
|
+
context_window=1048576, # 1.05M tokens (OpenRouter API is authoritative)
|
|
842
|
+
max_completion_tokens=262144, # 256K max output
|
|
843
|
+
pricing=ModelPricing(input_price=1.20, output_price=4.10), # OpenRouter models API verified 2026-06-20
|
|
844
|
+
capabilities=ModelCapabilities(
|
|
845
|
+
supports_vision=False, # text->text
|
|
846
|
+
supports_function_calling=True,
|
|
847
|
+
supports_tools=True,
|
|
848
|
+
supports_streaming=True,
|
|
849
|
+
supports_json_mode=True, # response_format + structured_outputs
|
|
850
|
+
supports_thinking=True, # reasoning param ("reasoning"/include_reasoning)
|
|
851
|
+
thinking_budget_tokens=32000, # consumed only when THINKING_CONFIG_ENABLED
|
|
852
|
+
),
|
|
853
|
+
knowledge_cutoff="2026-04",
|
|
854
|
+
aliases=["glm", "glm-5.2", "glm5.2", "z-ai/glm"]
|
|
855
|
+
))
|
|
856
|
+
|
|
857
|
+
# GLM-5 - balanced Gen-5 GLM (203K ctx). Cheaper/faster alternative to the
|
|
858
|
+
# 5.2 flagship; same native tools + reasoning + structured outputs, text-only.
|
|
859
|
+
self._register_model(ModelConfig(
|
|
860
|
+
name="z-ai/glm-5",
|
|
861
|
+
provider=ModelProvider.OPENROUTER,
|
|
862
|
+
context_window=202752, # 203K tokens
|
|
863
|
+
max_completion_tokens=131072, # family cap (OpenRouter API authoritative)
|
|
864
|
+
pricing=ModelPricing(input_price=0.60, output_price=1.92),
|
|
865
|
+
capabilities=ModelCapabilities(
|
|
866
|
+
supports_vision=False,
|
|
867
|
+
supports_function_calling=True,
|
|
868
|
+
supports_tools=True,
|
|
869
|
+
supports_streaming=True,
|
|
870
|
+
supports_json_mode=True,
|
|
871
|
+
supports_thinking=True,
|
|
872
|
+
thinking_budget_tokens=32000,
|
|
873
|
+
),
|
|
874
|
+
knowledge_cutoff="2026-04",
|
|
875
|
+
aliases=["glm-5", "glm5"]
|
|
876
|
+
))
|
|
877
|
+
|
|
878
|
+
# GLM-4.7 - cheapest proven GLM (203K ctx). Lowest latency/cost of the GLM
|
|
879
|
+
# family registered here; native tools + reasoning + structured outputs, text-only.
|
|
880
|
+
self._register_model(ModelConfig(
|
|
881
|
+
name="z-ai/glm-4.7",
|
|
882
|
+
provider=ModelProvider.OPENROUTER,
|
|
883
|
+
context_window=202752, # 203K tokens
|
|
884
|
+
max_completion_tokens=131072, # 128K max output
|
|
885
|
+
pricing=ModelPricing(input_price=0.40, output_price=1.75),
|
|
886
|
+
capabilities=ModelCapabilities(
|
|
887
|
+
supports_vision=False,
|
|
888
|
+
supports_function_calling=True,
|
|
889
|
+
supports_tools=True,
|
|
890
|
+
supports_streaming=True,
|
|
891
|
+
supports_json_mode=True,
|
|
892
|
+
supports_thinking=True,
|
|
893
|
+
thinking_budget_tokens=32000,
|
|
894
|
+
),
|
|
895
|
+
knowledge_cutoff="2026-01",
|
|
896
|
+
aliases=["glm-4.7", "glm4.7"]
|
|
897
|
+
))
|
|
898
|
+
|
|
899
|
+
# ----------------------------------------
|
|
900
|
+
# GROK MODELS (xAI via OpenRouter)
|
|
901
|
+
# https://openrouter.ai/provider/xai
|
|
902
|
+
# ----------------------------------------
|
|
903
|
+
|
|
904
|
+
# Grok 4.3 - current xAI flagship on OpenRouter (default for `--provider
|
|
905
|
+
# openrouter`). xAI deprecated grok-4.1-fast (404s with a "switch to Grok
|
|
906
|
+
# 4.3" message), so 4.3 is the preferred entry. Context/pricing mirror the
|
|
907
|
+
# recent grok family; the OpenRouter API enforces the authoritative limits.
|
|
908
|
+
self._register_model(ModelConfig(
|
|
909
|
+
name="x-ai/grok-4.3",
|
|
910
|
+
provider=ModelProvider.OPENROUTER,
|
|
911
|
+
context_window=2000000, # 2M tokens (family value; API is authoritative)
|
|
912
|
+
max_completion_tokens=30000,
|
|
913
|
+
pricing=ModelPricing(input_price=1.25, output_price=2.50), # OpenRouter models API verified 2026-06-20 (was 0.20/0.50 — ~5x too low)
|
|
914
|
+
capabilities=ModelCapabilities(
|
|
915
|
+
supports_vision=True,
|
|
916
|
+
supports_function_calling=True,
|
|
917
|
+
supports_streaming=True,
|
|
918
|
+
supports_json_mode=True,
|
|
919
|
+
supports_thinking=True
|
|
920
|
+
),
|
|
921
|
+
knowledge_cutoff="2025-11",
|
|
922
|
+
aliases=["grok-4.3", "grok-43", "grok"]
|
|
923
|
+
))
|
|
924
|
+
|
|
925
|
+
# Grok 4.1 Fast - DEPRECATED by xAI (kept for back-compat / historical ids;
|
|
926
|
+
# OpenRouter now 404s this model and recommends Grok 4.3 above).
|
|
927
|
+
# Created: Nov 19, 2025 | 2M context, web search, reasoning toggle
|
|
928
|
+
self._register_model(ModelConfig(
|
|
929
|
+
name="x-ai/grok-4.1-fast",
|
|
930
|
+
provider=ModelProvider.OPENROUTER,
|
|
931
|
+
context_window=2000000, # 2M tokens
|
|
932
|
+
max_completion_tokens=30000, # Verified from OpenRouter docs
|
|
933
|
+
pricing=ModelPricing(input_price=0.20, output_price=0.50), # $0.40/$1.00 above 128k
|
|
934
|
+
capabilities=ModelCapabilities(
|
|
935
|
+
supports_vision=True,
|
|
936
|
+
supports_function_calling=True,
|
|
937
|
+
supports_streaming=True,
|
|
938
|
+
supports_json_mode=True,
|
|
939
|
+
supports_thinking=True # Reasoning can be toggled
|
|
940
|
+
),
|
|
941
|
+
knowledge_cutoff="2025-11",
|
|
942
|
+
aliases=["grok-4.1-fast", "grok-4-1-fast", "grok-41-fast"]
|
|
943
|
+
))
|
|
944
|
+
|
|
945
|
+
# Grok 4 Fast - Multimodal with 2M context
|
|
946
|
+
# Created: Sep 19, 2025 | Non-reasoning and reasoning flavors
|
|
947
|
+
self._register_model(ModelConfig(
|
|
948
|
+
name="x-ai/grok-4-fast",
|
|
949
|
+
provider=ModelProvider.OPENROUTER,
|
|
950
|
+
context_window=2000000, # 2M tokens
|
|
951
|
+
max_completion_tokens=30000, # Verified from OpenRouter docs
|
|
952
|
+
pricing=ModelPricing(input_price=0.20, output_price=0.50), # $0.40/$1.00 above 128k
|
|
953
|
+
capabilities=ModelCapabilities(
|
|
954
|
+
supports_vision=True,
|
|
955
|
+
supports_function_calling=True,
|
|
956
|
+
supports_streaming=True,
|
|
957
|
+
supports_json_mode=True,
|
|
958
|
+
supports_thinking=True # Reasoning can be toggled
|
|
959
|
+
),
|
|
960
|
+
knowledge_cutoff="2025-09",
|
|
961
|
+
aliases=["grok-4-fast", "grok4-fast"]
|
|
962
|
+
))
|
|
963
|
+
|
|
964
|
+
# Grok 4 - Reasoning model (mandatory reasoning)
|
|
965
|
+
# Created: Jul 9, 2025 | 256K context, reasoning always on
|
|
966
|
+
self._register_model(ModelConfig(
|
|
967
|
+
name="x-ai/grok-4",
|
|
968
|
+
provider=ModelProvider.OPENROUTER,
|
|
969
|
+
context_window=256000, # 256K tokens
|
|
970
|
+
max_completion_tokens=32768, # Not specified, conservative estimate
|
|
971
|
+
pricing=ModelPricing(input_price=3.00, output_price=15.00), # $6/$30 above 128k
|
|
972
|
+
capabilities=ModelCapabilities(
|
|
973
|
+
supports_vision=True,
|
|
974
|
+
supports_function_calling=True,
|
|
975
|
+
supports_thinking=True, # Always on, cannot be disabled
|
|
976
|
+
supports_streaming=True,
|
|
977
|
+
supports_json_mode=True
|
|
978
|
+
),
|
|
979
|
+
knowledge_cutoff="2025-07",
|
|
980
|
+
aliases=["grok-4", "grok4"]
|
|
981
|
+
))
|
|
982
|
+
|
|
983
|
+
# Grok Code Fast 1 - Agentic coding specialist
|
|
984
|
+
# Created: Aug 26, 2025 | 256K context, visible reasoning traces
|
|
985
|
+
self._register_model(ModelConfig(
|
|
986
|
+
name="x-ai/grok-code-fast-1",
|
|
987
|
+
provider=ModelProvider.OPENROUTER,
|
|
988
|
+
context_window=256000, # 256K tokens - verified
|
|
989
|
+
max_completion_tokens=10000, # Verified from OpenRouter docs
|
|
990
|
+
pricing=ModelPricing(input_price=0.20, output_price=1.50),
|
|
991
|
+
capabilities=ModelCapabilities(
|
|
992
|
+
supports_function_calling=True,
|
|
993
|
+
supports_thinking=True, # Visible reasoning traces
|
|
994
|
+
supports_streaming=True,
|
|
995
|
+
supports_json_mode=True
|
|
996
|
+
),
|
|
997
|
+
knowledge_cutoff="2025-08",
|
|
998
|
+
aliases=["grok-code-fast", "grok-code-1", "grok-code"]
|
|
999
|
+
))
|
|
1000
|
+
|
|
1001
|
+
# Grok 3 - Enterprise model with deep domain knowledge
|
|
1002
|
+
# Created: Jun 10, 2025 | Finance, healthcare, law, science
|
|
1003
|
+
self._register_model(ModelConfig(
|
|
1004
|
+
name="x-ai/grok-3",
|
|
1005
|
+
provider=ModelProvider.OPENROUTER,
|
|
1006
|
+
context_window=131072, # 131K tokens - verified
|
|
1007
|
+
max_completion_tokens=32768,
|
|
1008
|
+
pricing=ModelPricing(input_price=3.00, output_price=15.00), # Higher above 128k
|
|
1009
|
+
capabilities=ModelCapabilities(
|
|
1010
|
+
supports_function_calling=True,
|
|
1011
|
+
supports_streaming=True,
|
|
1012
|
+
supports_json_mode=True
|
|
1013
|
+
),
|
|
1014
|
+
knowledge_cutoff="2025-06",
|
|
1015
|
+
aliases=["grok-3", "grok3"]
|
|
1016
|
+
))
|
|
1017
|
+
|
|
1018
|
+
# Grok 3 Mini - Lightweight thinking model
|
|
1019
|
+
# Created: Jun 10, 2025 | Fast, logic-based tasks
|
|
1020
|
+
self._register_model(ModelConfig(
|
|
1021
|
+
name="x-ai/grok-3-mini",
|
|
1022
|
+
provider=ModelProvider.OPENROUTER,
|
|
1023
|
+
context_window=131072, # 131K tokens - verified
|
|
1024
|
+
max_completion_tokens=32768,
|
|
1025
|
+
pricing=ModelPricing(input_price=0.30, output_price=0.50),
|
|
1026
|
+
capabilities=ModelCapabilities(
|
|
1027
|
+
supports_function_calling=True,
|
|
1028
|
+
supports_thinking=True, # Thinks before responding
|
|
1029
|
+
supports_streaming=True
|
|
1030
|
+
),
|
|
1031
|
+
knowledge_cutoff="2025-06",
|
|
1032
|
+
aliases=["grok-3-mini", "grok3-mini"]
|
|
1033
|
+
))
|
|
1034
|
+
|
|
1035
|
+
# ----------------------------------------
|
|
1036
|
+
# KIMI MODELS (Moonshot AI via OpenRouter)
|
|
1037
|
+
# 1T params MoE, 32B active per forward pass
|
|
1038
|
+
# NOTE: Kimi K2 models are TEXT-ONLY, no vision support
|
|
1039
|
+
# ----------------------------------------
|
|
1040
|
+
|
|
1041
|
+
# Kimi K2 0905 - September 2025 update
|
|
1042
|
+
# 262K context (extended from 128K), improved agentic coding
|
|
1043
|
+
self._register_model(ModelConfig(
|
|
1044
|
+
name="moonshotai/kimi-k2-0905",
|
|
1045
|
+
provider=ModelProvider.OPENROUTER,
|
|
1046
|
+
context_window=262144, # 262K tokens - verified (extended)
|
|
1047
|
+
max_completion_tokens=262144, # Can match context - verified
|
|
1048
|
+
pricing=ModelPricing(input_price=0.39, output_price=1.90),
|
|
1049
|
+
capabilities=ModelCapabilities(
|
|
1050
|
+
supports_vision=False, # TEXT-ONLY - no image support
|
|
1051
|
+
supports_function_calling=True,
|
|
1052
|
+
supports_streaming=True,
|
|
1053
|
+
supports_json_mode=True
|
|
1054
|
+
),
|
|
1055
|
+
knowledge_cutoff="2025-09",
|
|
1056
|
+
aliases=["kimi-k2-0905", "kimi-k2", "kimi"]
|
|
1057
|
+
))
|
|
1058
|
+
|
|
1059
|
+
# Kimi K2 0711 - Original July release
|
|
1060
|
+
# 128K context, strong coding benchmarks
|
|
1061
|
+
self._register_model(ModelConfig(
|
|
1062
|
+
name="moonshotai/kimi-k2",
|
|
1063
|
+
provider=ModelProvider.OPENROUTER,
|
|
1064
|
+
context_window=131072, # 131K tokens - verified
|
|
1065
|
+
max_completion_tokens=131072, # Can match context
|
|
1066
|
+
pricing=ModelPricing(input_price=0.456, output_price=1.84),
|
|
1067
|
+
capabilities=ModelCapabilities(
|
|
1068
|
+
supports_vision=False, # TEXT-ONLY - no image support
|
|
1069
|
+
supports_function_calling=True,
|
|
1070
|
+
supports_streaming=True,
|
|
1071
|
+
supports_json_mode=True
|
|
1072
|
+
),
|
|
1073
|
+
knowledge_cutoff="2025-07",
|
|
1074
|
+
aliases=["kimi-k2-0711"]
|
|
1075
|
+
))
|
|
1076
|
+
|
|
1077
|
+
# Kimi K2 Thinking - Advanced reasoning model
|
|
1078
|
+
# Created: Nov 6, 2025 | 200-300 tool calls stability
|
|
1079
|
+
self._register_model(ModelConfig(
|
|
1080
|
+
name="moonshotai/kimi-k2-thinking",
|
|
1081
|
+
provider=ModelProvider.OPENROUTER,
|
|
1082
|
+
context_window=262144, # 262K tokens - verified
|
|
1083
|
+
max_completion_tokens=16384, # Verified from OpenRouter docs
|
|
1084
|
+
pricing=ModelPricing(input_price=0.45, output_price=2.35),
|
|
1085
|
+
capabilities=ModelCapabilities(
|
|
1086
|
+
supports_vision=False, # TEXT-ONLY - no image support
|
|
1087
|
+
supports_function_calling=True,
|
|
1088
|
+
supports_thinking=True, # Step-by-step reasoning
|
|
1089
|
+
supports_streaming=True
|
|
1090
|
+
),
|
|
1091
|
+
knowledge_cutoff="2025-11",
|
|
1092
|
+
aliases=["kimi-k2-thinking", "kimi-thinking"]
|
|
1093
|
+
))
|
|
1094
|
+
|
|
1095
|
+
# ========================================
|
|
1096
|
+
# NVIDIA NIM MODELS (OpenAI-compatible, free hosted inference)
|
|
1097
|
+
# Access via https://integrate.api.nvidia.com/v1
|
|
1098
|
+
# build.nvidia.com offers a free tier — useful for endless testing.
|
|
1099
|
+
# ========================================
|
|
1100
|
+
|
|
1101
|
+
# Kimi K2.6 - Moonshot's flagship served on NVIDIA NIM (free tier).
|
|
1102
|
+
# TEXT-ONLY (no vision); strong agentic/tool-calling. The provider id is
|
|
1103
|
+
# what NVIDIA expects on the wire: "moonshotai/kimi-k2.6".
|
|
1104
|
+
self._register_model(ModelConfig(
|
|
1105
|
+
name="moonshotai/kimi-k2.6",
|
|
1106
|
+
provider=ModelProvider.NVIDIA,
|
|
1107
|
+
context_window=262144, # 262K tokens (Kimi K2 family)
|
|
1108
|
+
max_completion_tokens=16384, # NVIDIA NIM default cap for this model
|
|
1109
|
+
pricing=ModelPricing(input_price=0.0, output_price=0.0), # free hosted tier
|
|
1110
|
+
capabilities=ModelCapabilities(
|
|
1111
|
+
supports_vision=False, # TEXT-ONLY - no image support
|
|
1112
|
+
supports_function_calling=True,
|
|
1113
|
+
supports_streaming=True,
|
|
1114
|
+
supports_json_mode=True
|
|
1115
|
+
),
|
|
1116
|
+
knowledge_cutoff="2025-11",
|
|
1117
|
+
aliases=["kimi-k2.6", "kimi-k26", "kimi-2.6"]
|
|
1118
|
+
))
|
|
1119
|
+
|
|
1120
|
+
# ----------------------------------------
|
|
1121
|
+
# QWEN MODELS (Alibaba via OpenRouter)
|
|
1122
|
+
# https://openrouter.ai/qwen
|
|
1123
|
+
# NOTE: Most Qwen3 models are TEXT-ONLY. Only Qwen3-VL models support vision.
|
|
1124
|
+
# ----------------------------------------
|
|
1125
|
+
|
|
1126
|
+
# Qwen3 235B A22B - Flagship MoE model
|
|
1127
|
+
# 235B total, 22B active per forward pass
|
|
1128
|
+
self._register_model(ModelConfig(
|
|
1129
|
+
name="qwen/qwen3-235b-a22b",
|
|
1130
|
+
provider=ModelProvider.OPENROUTER,
|
|
1131
|
+
context_window=131072, # 131K with YaRN scaling - native 40K
|
|
1132
|
+
max_completion_tokens=40960, # Verified from OpenRouter docs
|
|
1133
|
+
pricing=ModelPricing(input_price=0.455, output_price=1.82), # OpenRouter models API verified 2026-06-20 (was 0.18/0.54 — ~3.4x too low)
|
|
1134
|
+
capabilities=ModelCapabilities(
|
|
1135
|
+
supports_vision=False, # TEXT-ONLY - no image support
|
|
1136
|
+
supports_function_calling=True,
|
|
1137
|
+
supports_thinking=True, # Dual mode: thinking/non-thinking
|
|
1138
|
+
supports_streaming=True,
|
|
1139
|
+
supports_json_mode=True
|
|
1140
|
+
),
|
|
1141
|
+
knowledge_cutoff="2025-04",
|
|
1142
|
+
aliases=["qwen3-235b-a22b", "qwen3-235b", "qwen-235b", "qwen3"]
|
|
1143
|
+
))
|
|
1144
|
+
|
|
1145
|
+
# Qwen3 Max - Updated flagship (Sep 2025)
|
|
1146
|
+
# Major improvements in reasoning, 100+ languages
|
|
1147
|
+
self._register_model(ModelConfig(
|
|
1148
|
+
name="qwen/qwen3-max",
|
|
1149
|
+
provider=ModelProvider.OPENROUTER,
|
|
1150
|
+
context_window=256000, # 256K tokens - verified
|
|
1151
|
+
max_completion_tokens=32768, # Verified from OpenRouter docs
|
|
1152
|
+
pricing=ModelPricing(input_price=0.78, output_price=3.90), # OpenRouter models API verified 2026-06-20 (was 1.20/6.00)
|
|
1153
|
+
capabilities=ModelCapabilities(
|
|
1154
|
+
supports_vision=False, # TEXT-ONLY - no image support
|
|
1155
|
+
supports_function_calling=True,
|
|
1156
|
+
supports_streaming=True,
|
|
1157
|
+
supports_json_mode=True
|
|
1158
|
+
),
|
|
1159
|
+
knowledge_cutoff="2025-09",
|
|
1160
|
+
aliases=["qwen3-max", "qwen-max"]
|
|
1161
|
+
))
|
|
1162
|
+
|
|
1163
|
+
# Qwen3 Coder 480B A35B - Code generation specialist
|
|
1164
|
+
# Created: Jul 23, 2025 | 480B total, 35B active (8/160 experts)
|
|
1165
|
+
self._register_model(ModelConfig(
|
|
1166
|
+
name="qwen/qwen3-coder",
|
|
1167
|
+
provider=ModelProvider.OPENROUTER,
|
|
1168
|
+
context_window=262144, # 262K tokens - verified
|
|
1169
|
+
max_completion_tokens=262144, # Can match context
|
|
1170
|
+
pricing=ModelPricing(input_price=0.22, output_price=0.95), # Higher above 128k
|
|
1171
|
+
capabilities=ModelCapabilities(
|
|
1172
|
+
supports_vision=False, # TEXT-ONLY - no image support
|
|
1173
|
+
supports_function_calling=True,
|
|
1174
|
+
supports_streaming=True
|
|
1175
|
+
),
|
|
1176
|
+
knowledge_cutoff="2025-07",
|
|
1177
|
+
aliases=["qwen3-coder-480b", "qwen-coder", "qwen3-coder", "qwen3-coder-480b-a35b"]
|
|
1178
|
+
))
|
|
1179
|
+
|
|
1180
|
+
# Qwen3 32B - Dense model with thinking mode
|
|
1181
|
+
# Created: Apr 28, 2025 | 32.8B params, 100+ languages
|
|
1182
|
+
# NOTE: This is a TEXT-ONLY model, NOT vision capable
|
|
1183
|
+
self._register_model(ModelConfig(
|
|
1184
|
+
name="qwen/qwen3-32b",
|
|
1185
|
+
provider=ModelProvider.OPENROUTER,
|
|
1186
|
+
context_window=131072, # 131K with YaRN - native 40K
|
|
1187
|
+
max_completion_tokens=40960, # Verified from OpenRouter docs
|
|
1188
|
+
pricing=ModelPricing(input_price=0.08, output_price=0.24),
|
|
1189
|
+
capabilities=ModelCapabilities(
|
|
1190
|
+
supports_vision=False, # TEXT-ONLY - no image support
|
|
1191
|
+
supports_function_calling=True,
|
|
1192
|
+
supports_thinking=True, # Dual mode
|
|
1193
|
+
supports_streaming=True
|
|
1194
|
+
),
|
|
1195
|
+
knowledge_cutoff="2025-04",
|
|
1196
|
+
aliases=["qwen3-32b", "qwen-32b"]
|
|
1197
|
+
))
|
|
1198
|
+
|
|
1199
|
+
# Qwen3 VL 235B A22B Instruct - Vision-Language model
|
|
1200
|
+
# Created: Sep 23, 2025 | VQA, document parsing, video understanding
|
|
1201
|
+
self._register_model(ModelConfig(
|
|
1202
|
+
name="qwen/qwen3-vl-235b-a22b-instruct",
|
|
1203
|
+
provider=ModelProvider.OPENROUTER,
|
|
1204
|
+
context_window=262144, # 262K tokens - verified
|
|
1205
|
+
max_completion_tokens=32768,
|
|
1206
|
+
pricing=ModelPricing(input_price=0.20, output_price=1.20),
|
|
1207
|
+
capabilities=ModelCapabilities(
|
|
1208
|
+
supports_vision=True, # Images and video
|
|
1209
|
+
supports_function_calling=True,
|
|
1210
|
+
supports_streaming=True
|
|
1211
|
+
),
|
|
1212
|
+
knowledge_cutoff="2025-09",
|
|
1213
|
+
aliases=["qwen3-vl-235b", "qwen-vl", "qwen3-vl"]
|
|
1214
|
+
))
|
|
1215
|
+
|
|
1216
|
+
# ----------------------------------------
|
|
1217
|
+
# DEEPSEEK MODELS (via OpenRouter)
|
|
1218
|
+
# https://openrouter.ai/deepseek
|
|
1219
|
+
# DeepSeek V3 with OpenRouter's tool calling support
|
|
1220
|
+
# ----------------------------------------
|
|
1221
|
+
|
|
1222
|
+
# DeepSeek Chat V3 via OpenRouter - Tool calling supported
|
|
1223
|
+
# 671B total params, 37B active (MoE architecture)
|
|
1224
|
+
self._register_model(ModelConfig(
|
|
1225
|
+
name="deepseek/deepseek-chat",
|
|
1226
|
+
provider=ModelProvider.OPENROUTER,
|
|
1227
|
+
context_window=128000, # 128K context
|
|
1228
|
+
max_completion_tokens=8192, # 8K output
|
|
1229
|
+
pricing=ModelPricing(
|
|
1230
|
+
input_price=0.14, # OpenRouter pricing
|
|
1231
|
+
output_price=0.28
|
|
1232
|
+
),
|
|
1233
|
+
capabilities=ModelCapabilities(
|
|
1234
|
+
supports_vision=False, # Text only
|
|
1235
|
+
supports_function_calling=True, # Tool calling via OpenRouter
|
|
1236
|
+
supports_tools=True,
|
|
1237
|
+
supports_streaming=True,
|
|
1238
|
+
supports_json_mode=True
|
|
1239
|
+
),
|
|
1240
|
+
knowledge_cutoff="2025-12",
|
|
1241
|
+
aliases=["openrouter-deepseek", "openrouter-deepseek-chat", "deepseek-openrouter", "or-deepseek"]
|
|
1242
|
+
))
|
|
1243
|
+
|
|
1244
|
+
# DeepSeek R1 Reasoning via OpenRouter
|
|
1245
|
+
# Extended thinking with tool support
|
|
1246
|
+
self._register_model(ModelConfig(
|
|
1247
|
+
name="deepseek/deepseek-r1",
|
|
1248
|
+
provider=ModelProvider.OPENROUTER,
|
|
1249
|
+
context_window=128000, # 128K context
|
|
1250
|
+
max_completion_tokens=64000, # 64K output for reasoning
|
|
1251
|
+
pricing=ModelPricing(
|
|
1252
|
+
input_price=0.55, # Higher for reasoning
|
|
1253
|
+
output_price=2.19
|
|
1254
|
+
),
|
|
1255
|
+
capabilities=ModelCapabilities(
|
|
1256
|
+
supports_vision=False, # Text only
|
|
1257
|
+
supports_function_calling=True, # Tool calling via OpenRouter
|
|
1258
|
+
supports_tools=True,
|
|
1259
|
+
supports_thinking=True, # Reasoning model
|
|
1260
|
+
supports_streaming=True
|
|
1261
|
+
),
|
|
1262
|
+
knowledge_cutoff="2025-12",
|
|
1263
|
+
aliases=["openrouter-deepseek-r1", "deepseek-r1-openrouter", "or-deepseek-r1"]
|
|
1264
|
+
))
|
|
1265
|
+
|
|
1266
|
+
# DeepSeek R1 Distill Qwen 32B - Smaller reasoning model
|
|
1267
|
+
# Distilled from R1 into Qwen 32B architecture
|
|
1268
|
+
self._register_model(ModelConfig(
|
|
1269
|
+
name="deepseek/deepseek-r1-distill-qwen-32b",
|
|
1270
|
+
provider=ModelProvider.OPENROUTER,
|
|
1271
|
+
context_window=131072, # 131K context
|
|
1272
|
+
max_completion_tokens=16384, # 16K output
|
|
1273
|
+
pricing=ModelPricing(
|
|
1274
|
+
input_price=0.12, # Cheaper distilled model
|
|
1275
|
+
output_price=0.18
|
|
1276
|
+
),
|
|
1277
|
+
capabilities=ModelCapabilities(
|
|
1278
|
+
supports_vision=False,
|
|
1279
|
+
supports_function_calling=True,
|
|
1280
|
+
supports_tools=True,
|
|
1281
|
+
supports_thinking=True,
|
|
1282
|
+
supports_streaming=True
|
|
1283
|
+
),
|
|
1284
|
+
knowledge_cutoff="2025-01",
|
|
1285
|
+
aliases=["deepseek-r1-distill-qwen", "deepseek-r1-qwen-32b", "or-deepseek-r1-distill"]
|
|
1286
|
+
))
|
|
1287
|
+
|
|
1288
|
+
# ========================================
|
|
1289
|
+
# CURATED OPENROUTER SHORTLIST EXPANSION (2026-06-24)
|
|
1290
|
+
# Models ROB has no native client for (OpenRouter's real value). Pricing +
|
|
1291
|
+
# specs verified against the live OpenRouter models API on 2026-06-24
|
|
1292
|
+
# (GET https://openrouter.ai/api/v1/models). Pinned in
|
|
1293
|
+
# tests/unit/modules/llm/test_openrouter_pricing_verified_2026_06_24.py.
|
|
1294
|
+
# ========================================
|
|
1295
|
+
|
|
1296
|
+
# --- Frontier agentic / coding ---
|
|
1297
|
+
|
|
1298
|
+
# Moonshot Kimi K2.5 — strong agentic; ROB otherwise only has Kimi via NIM.
|
|
1299
|
+
# Multimodal (image input) on OpenRouter, native tools + reasoning.
|
|
1300
|
+
self._register_model(ModelConfig(
|
|
1301
|
+
name="moonshotai/kimi-k2.5",
|
|
1302
|
+
provider=ModelProvider.OPENROUTER,
|
|
1303
|
+
context_window=262144,
|
|
1304
|
+
max_completion_tokens=32768,
|
|
1305
|
+
pricing=ModelPricing(input_price=0.375, output_price=2.025),
|
|
1306
|
+
capabilities=ModelCapabilities(
|
|
1307
|
+
supports_vision=True, supports_function_calling=True,
|
|
1308
|
+
supports_tools=True, supports_streaming=True,
|
|
1309
|
+
supports_json_mode=True, supports_thinking=True,
|
|
1310
|
+
),
|
|
1311
|
+
knowledge_cutoff="2025-10",
|
|
1312
|
+
aliases=["kimi-k2.5", "kimi-k25", "or-kimi"]
|
|
1313
|
+
))
|
|
1314
|
+
|
|
1315
|
+
# MiniMax M2 — strong agentic-coding MoE; prompt-cache read priced.
|
|
1316
|
+
self._register_model(ModelConfig(
|
|
1317
|
+
name="minimax/minimax-m2",
|
|
1318
|
+
provider=ModelProvider.OPENROUTER,
|
|
1319
|
+
context_window=204800,
|
|
1320
|
+
max_completion_tokens=196608,
|
|
1321
|
+
pricing=ModelPricing(input_price=0.255, cached_input_price=0.03, output_price=1.0),
|
|
1322
|
+
capabilities=ModelCapabilities(
|
|
1323
|
+
supports_vision=False, supports_function_calling=True,
|
|
1324
|
+
supports_tools=True, supports_streaming=True,
|
|
1325
|
+
supports_json_mode=True, supports_thinking=True,
|
|
1326
|
+
),
|
|
1327
|
+
knowledge_cutoff="2025-09",
|
|
1328
|
+
aliases=["minimax-m2", "minimax2"]
|
|
1329
|
+
))
|
|
1330
|
+
|
|
1331
|
+
# GLM-4.6 — cheaper GLM tier below 5.2; native tools + reasoning, cache read priced.
|
|
1332
|
+
self._register_model(ModelConfig(
|
|
1333
|
+
name="z-ai/glm-4.6",
|
|
1334
|
+
provider=ModelProvider.OPENROUTER,
|
|
1335
|
+
context_window=202752,
|
|
1336
|
+
max_completion_tokens=131072,
|
|
1337
|
+
pricing=ModelPricing(input_price=0.43, cached_input_price=0.08, output_price=1.74),
|
|
1338
|
+
capabilities=ModelCapabilities(
|
|
1339
|
+
supports_vision=False, supports_function_calling=True,
|
|
1340
|
+
supports_tools=True, supports_streaming=True,
|
|
1341
|
+
supports_json_mode=True, supports_thinking=True,
|
|
1342
|
+
thinking_budget_tokens=32000,
|
|
1343
|
+
),
|
|
1344
|
+
knowledge_cutoff="2025-12",
|
|
1345
|
+
aliases=["glm-4.6", "glm4.6"]
|
|
1346
|
+
))
|
|
1347
|
+
|
|
1348
|
+
# Qwen3 Coder 30B-A3B — cheap dedicated coder, native tools.
|
|
1349
|
+
self._register_model(ModelConfig(
|
|
1350
|
+
name="qwen/qwen3-coder-30b-a3b-instruct",
|
|
1351
|
+
provider=ModelProvider.OPENROUTER,
|
|
1352
|
+
context_window=160000,
|
|
1353
|
+
max_completion_tokens=32768,
|
|
1354
|
+
pricing=ModelPricing(input_price=0.07, output_price=0.27),
|
|
1355
|
+
capabilities=ModelCapabilities(
|
|
1356
|
+
supports_vision=False, supports_function_calling=True,
|
|
1357
|
+
supports_tools=True, supports_streaming=True, supports_json_mode=True,
|
|
1358
|
+
),
|
|
1359
|
+
knowledge_cutoff="2025-07",
|
|
1360
|
+
aliases=["qwen3-coder-30b", "qwen3-coder-flash"]
|
|
1361
|
+
))
|
|
1362
|
+
|
|
1363
|
+
# --- Cheap high-volume workhorses ---
|
|
1364
|
+
|
|
1365
|
+
# DeepSeek V3.2 — latest DeepSeek, very cheap output, native tools + reasoning.
|
|
1366
|
+
self._register_model(ModelConfig(
|
|
1367
|
+
name="deepseek/deepseek-v3.2",
|
|
1368
|
+
provider=ModelProvider.OPENROUTER,
|
|
1369
|
+
context_window=131072,
|
|
1370
|
+
max_completion_tokens=64000,
|
|
1371
|
+
pricing=ModelPricing(input_price=0.2288, output_price=0.3432),
|
|
1372
|
+
capabilities=ModelCapabilities(
|
|
1373
|
+
supports_vision=False, supports_function_calling=True,
|
|
1374
|
+
supports_tools=True, supports_streaming=True,
|
|
1375
|
+
supports_json_mode=True, supports_thinking=True,
|
|
1376
|
+
),
|
|
1377
|
+
knowledge_cutoff="2025-07",
|
|
1378
|
+
aliases=["deepseek-v3.2", "or-deepseek-v3.2"]
|
|
1379
|
+
))
|
|
1380
|
+
|
|
1381
|
+
# DeepSeek V4 Flash — cheapest capable + 1M context, cache read priced.
|
|
1382
|
+
self._register_model(ModelConfig(
|
|
1383
|
+
name="deepseek/deepseek-v4-flash",
|
|
1384
|
+
provider=ModelProvider.OPENROUTER,
|
|
1385
|
+
context_window=1048576,
|
|
1386
|
+
max_completion_tokens=65536,
|
|
1387
|
+
pricing=ModelPricing(input_price=0.09, cached_input_price=0.02, output_price=0.18),
|
|
1388
|
+
capabilities=ModelCapabilities(
|
|
1389
|
+
supports_vision=False, supports_function_calling=True,
|
|
1390
|
+
supports_tools=True, supports_streaming=True,
|
|
1391
|
+
supports_json_mode=True, supports_thinking=True,
|
|
1392
|
+
),
|
|
1393
|
+
knowledge_cutoff="2025-12",
|
|
1394
|
+
aliases=["deepseek-v4-flash", "deepseek-flash"]
|
|
1395
|
+
))
|
|
1396
|
+
|
|
1397
|
+
# Llama 3.3 70B Instruct — reliable open workhorse, native tools.
|
|
1398
|
+
self._register_model(ModelConfig(
|
|
1399
|
+
name="meta-llama/llama-3.3-70b-instruct",
|
|
1400
|
+
provider=ModelProvider.OPENROUTER,
|
|
1401
|
+
context_window=131072,
|
|
1402
|
+
max_completion_tokens=16384,
|
|
1403
|
+
pricing=ModelPricing(input_price=0.1, output_price=0.32),
|
|
1404
|
+
capabilities=ModelCapabilities(
|
|
1405
|
+
supports_vision=False, supports_function_calling=True,
|
|
1406
|
+
supports_tools=True, supports_streaming=True, supports_json_mode=True,
|
|
1407
|
+
),
|
|
1408
|
+
knowledge_cutoff="2024-12",
|
|
1409
|
+
aliases=["llama-3.3-70b", "llama3.3-70b"]
|
|
1410
|
+
))
|
|
1411
|
+
|
|
1412
|
+
# Mistral Small 3.2 24B — cheap European option, multimodal (image input).
|
|
1413
|
+
self._register_model(ModelConfig(
|
|
1414
|
+
name="mistralai/mistral-small-3.2-24b-instruct",
|
|
1415
|
+
provider=ModelProvider.OPENROUTER,
|
|
1416
|
+
context_window=128000,
|
|
1417
|
+
max_completion_tokens=16384,
|
|
1418
|
+
pricing=ModelPricing(input_price=0.075, output_price=0.2),
|
|
1419
|
+
capabilities=ModelCapabilities(
|
|
1420
|
+
supports_vision=True, supports_function_calling=True,
|
|
1421
|
+
supports_tools=True, supports_streaming=True, supports_json_mode=True,
|
|
1422
|
+
),
|
|
1423
|
+
knowledge_cutoff="2025-06",
|
|
1424
|
+
aliases=["mistral-small-3.2", "mistral-small"]
|
|
1425
|
+
))
|
|
1426
|
+
|
|
1427
|
+
# Qwen3 30B-A3B Instruct — very cheap qwen workhorse, native tools.
|
|
1428
|
+
self._register_model(ModelConfig(
|
|
1429
|
+
name="qwen/qwen3-30b-a3b-instruct-2507",
|
|
1430
|
+
provider=ModelProvider.OPENROUTER,
|
|
1431
|
+
context_window=131072,
|
|
1432
|
+
max_completion_tokens=32000,
|
|
1433
|
+
pricing=ModelPricing(input_price=0.04815, output_price=0.193),
|
|
1434
|
+
capabilities=ModelCapabilities(
|
|
1435
|
+
supports_vision=False, supports_function_calling=True,
|
|
1436
|
+
supports_tools=True, supports_streaming=True, supports_json_mode=True,
|
|
1437
|
+
),
|
|
1438
|
+
knowledge_cutoff="2025-07",
|
|
1439
|
+
aliases=["qwen3-30b-a3b", "qwen3-30b"]
|
|
1440
|
+
))
|
|
1441
|
+
|
|
1442
|
+
# --- Open-weights / OSS ---
|
|
1443
|
+
|
|
1444
|
+
# OpenAI gpt-oss-120b — OpenAI open-weights, extremely cheap, native tools + reasoning.
|
|
1445
|
+
self._register_model(ModelConfig(
|
|
1446
|
+
name="openai/gpt-oss-120b",
|
|
1447
|
+
provider=ModelProvider.OPENROUTER,
|
|
1448
|
+
context_window=131072,
|
|
1449
|
+
max_completion_tokens=32768,
|
|
1450
|
+
pricing=ModelPricing(input_price=0.039, output_price=0.18),
|
|
1451
|
+
capabilities=ModelCapabilities(
|
|
1452
|
+
supports_vision=False, supports_function_calling=True,
|
|
1453
|
+
supports_tools=True, supports_streaming=True,
|
|
1454
|
+
supports_json_mode=True, supports_thinking=True,
|
|
1455
|
+
),
|
|
1456
|
+
knowledge_cutoff="2024-06",
|
|
1457
|
+
aliases=["gpt-oss-120b", "gpt-oss"]
|
|
1458
|
+
))
|
|
1459
|
+
|
|
1460
|
+
# Nous Hermes 4 70B — ROB's parity benchmark. NOTE: OpenRouter does NOT
|
|
1461
|
+
# advertise the `tools` parameter for Hermes-4, so supports_tools=False →
|
|
1462
|
+
# the agent uses the JSON-from-text fallback (not native tool calls).
|
|
1463
|
+
self._register_model(ModelConfig(
|
|
1464
|
+
name="nousresearch/hermes-4-70b",
|
|
1465
|
+
provider=ModelProvider.OPENROUTER,
|
|
1466
|
+
context_window=131072,
|
|
1467
|
+
max_completion_tokens=16384,
|
|
1468
|
+
pricing=ModelPricing(input_price=0.13, output_price=0.4),
|
|
1469
|
+
capabilities=ModelCapabilities(
|
|
1470
|
+
supports_vision=False, supports_function_calling=False,
|
|
1471
|
+
supports_tools=False, supports_streaming=True,
|
|
1472
|
+
supports_json_mode=True, supports_thinking=True,
|
|
1473
|
+
),
|
|
1474
|
+
knowledge_cutoff="2024-12",
|
|
1475
|
+
aliases=["hermes-4-70b", "hermes4-70b"]
|
|
1476
|
+
))
|
|
1477
|
+
|
|
1478
|
+
# Nous Hermes 4 405B — flagship Hermes. Same no-native-tools caveat as 70B.
|
|
1479
|
+
self._register_model(ModelConfig(
|
|
1480
|
+
name="nousresearch/hermes-4-405b",
|
|
1481
|
+
provider=ModelProvider.OPENROUTER,
|
|
1482
|
+
context_window=131072,
|
|
1483
|
+
max_completion_tokens=16384,
|
|
1484
|
+
pricing=ModelPricing(input_price=1.0, output_price=3.0),
|
|
1485
|
+
capabilities=ModelCapabilities(
|
|
1486
|
+
supports_vision=False, supports_function_calling=False,
|
|
1487
|
+
supports_tools=False, supports_streaming=True,
|
|
1488
|
+
supports_json_mode=True, supports_thinking=True,
|
|
1489
|
+
),
|
|
1490
|
+
knowledge_cutoff="2024-12",
|
|
1491
|
+
aliases=["hermes-4-405b", "hermes4-405b", "hermes"]
|
|
1492
|
+
))
|
|
1493
|
+
|
|
1494
|
+
# --- Vision / long-context ---
|
|
1495
|
+
|
|
1496
|
+
# Qwen3-VL 8B Instruct — cheap vision (image input), native tools.
|
|
1497
|
+
self._register_model(ModelConfig(
|
|
1498
|
+
name="qwen/qwen3-vl-8b-instruct",
|
|
1499
|
+
provider=ModelProvider.OPENROUTER,
|
|
1500
|
+
context_window=256000,
|
|
1501
|
+
max_completion_tokens=32768,
|
|
1502
|
+
pricing=ModelPricing(input_price=0.08, output_price=0.5),
|
|
1503
|
+
capabilities=ModelCapabilities(
|
|
1504
|
+
supports_vision=True, supports_function_calling=True,
|
|
1505
|
+
supports_tools=True, supports_streaming=True, supports_json_mode=True,
|
|
1506
|
+
),
|
|
1507
|
+
knowledge_cutoff="2025-07",
|
|
1508
|
+
aliases=["qwen3-vl-8b", "qwen-vl-8b"]
|
|
1509
|
+
))
|
|
1510
|
+
|
|
1511
|
+
# Llama 4 Scout — extreme long-context (10M), multimodal, native tools.
|
|
1512
|
+
self._register_model(ModelConfig(
|
|
1513
|
+
name="meta-llama/llama-4-scout",
|
|
1514
|
+
provider=ModelProvider.OPENROUTER,
|
|
1515
|
+
context_window=10000000,
|
|
1516
|
+
max_completion_tokens=16384,
|
|
1517
|
+
pricing=ModelPricing(input_price=0.1, output_price=0.3),
|
|
1518
|
+
capabilities=ModelCapabilities(
|
|
1519
|
+
supports_vision=True, supports_function_calling=True,
|
|
1520
|
+
supports_tools=True, supports_streaming=True, supports_json_mode=True,
|
|
1521
|
+
),
|
|
1522
|
+
knowledge_cutoff="2024-08",
|
|
1523
|
+
aliases=["llama-4-scout", "llama4-scout"]
|
|
1524
|
+
))
|
|
1525
|
+
|
|
1526
|
+
# MiniMax M3 — long-context (1M) agentic, multimodal, reasoning, cache read priced.
|
|
1527
|
+
self._register_model(ModelConfig(
|
|
1528
|
+
name="minimax/minimax-m3",
|
|
1529
|
+
provider=ModelProvider.OPENROUTER,
|
|
1530
|
+
context_window=1048576,
|
|
1531
|
+
max_completion_tokens=512000,
|
|
1532
|
+
pricing=ModelPricing(input_price=0.3, cached_input_price=0.06, output_price=1.2),
|
|
1533
|
+
capabilities=ModelCapabilities(
|
|
1534
|
+
supports_vision=True, supports_function_calling=True,
|
|
1535
|
+
supports_tools=True, supports_streaming=True,
|
|
1536
|
+
supports_json_mode=True, supports_thinking=True,
|
|
1537
|
+
),
|
|
1538
|
+
knowledge_cutoff="2025-11",
|
|
1539
|
+
aliases=["minimax-m3", "minimax3"]
|
|
1540
|
+
))
|
|
1541
|
+
|
|
1542
|
+
def _register_model(self, config: ModelConfig):
|
|
1543
|
+
"""Register a model and its aliases"""
|
|
1544
|
+
# Register main name
|
|
1545
|
+
self._models[config.name] = config
|
|
1546
|
+
|
|
1547
|
+
# Register aliases
|
|
1548
|
+
for alias in config.aliases:
|
|
1549
|
+
self._aliases[alias] = config.name
|
|
1550
|
+
|
|
1551
|
+
logger.debug(f"Registered model: {config.name} with {len(config.aliases)} aliases")
|
|
1552
|
+
|
|
1553
|
+
def get_model(self, name: str) -> Optional[ModelConfig]:
|
|
1554
|
+
"""Get model configuration by name or alias with fallback support"""
|
|
1555
|
+
# Check if it's an alias
|
|
1556
|
+
canonical_name = self._aliases.get(name, name)
|
|
1557
|
+
|
|
1558
|
+
# Get model
|
|
1559
|
+
model = self._models.get(canonical_name)
|
|
1560
|
+
|
|
1561
|
+
if not model:
|
|
1562
|
+
logger.warning(f"Model '{name}' not found in registry, attempting fallback")
|
|
1563
|
+
|
|
1564
|
+
# Implement fallback logic based on model patterns
|
|
1565
|
+
model_lower = name.lower()
|
|
1566
|
+
|
|
1567
|
+
# OpenAI models: default to 5.1, fallback chain: 5.1 -> 4.1 -> 4o
|
|
1568
|
+
if any(x in model_lower for x in ['gpt', 'o1', 'o3', 'o4', 'openai']):
|
|
1569
|
+
# Try 5.1 first (latest default)
|
|
1570
|
+
model = self._models.get('gpt-5.1')
|
|
1571
|
+
if model:
|
|
1572
|
+
logger.info(f"Fallback: '{name}' -> 'gpt-5.1' (default)")
|
|
1573
|
+
else:
|
|
1574
|
+
# Fallback to 4.1
|
|
1575
|
+
model = self._models.get('gpt-4.1')
|
|
1576
|
+
if model:
|
|
1577
|
+
logger.info(f"Fallback: '{name}' -> 'gpt-4.1' (secondary)")
|
|
1578
|
+
else:
|
|
1579
|
+
# Fallback to 4o
|
|
1580
|
+
model = self._models.get('gpt-4o')
|
|
1581
|
+
if model:
|
|
1582
|
+
logger.info(f"Fallback: '{name}' -> 'gpt-4o' (tertiary)")
|
|
1583
|
+
# Claude variants fallback to claude-sonnet-4-5
|
|
1584
|
+
elif 'claude' in model_lower:
|
|
1585
|
+
model = self._models.get('claude-sonnet-4-5')
|
|
1586
|
+
if model:
|
|
1587
|
+
logger.info(f"Fallback: '{name}' -> 'claude-sonnet-4-5'")
|
|
1588
|
+
# Gemini variants fallback chain: 2.5-flash (stable) -> 3-pro-preview -> 2.5-pro
|
|
1589
|
+
elif 'gemini' in model_lower:
|
|
1590
|
+
# Check if user wants a specific series
|
|
1591
|
+
if '3' in model_lower or 'pro' in model_lower:
|
|
1592
|
+
# Try gemini-3-pro-preview first for pro/3 requests
|
|
1593
|
+
model = self._models.get('gemini-3-pro-preview')
|
|
1594
|
+
if model:
|
|
1595
|
+
logger.info(f"Fallback: '{name}' -> 'gemini-3-pro-preview'")
|
|
1596
|
+
if not model and ('flash' in model_lower or '2.5' in model_lower or '2.0' in model_lower):
|
|
1597
|
+
# Try 2.5-flash for flash/2.x requests
|
|
1598
|
+
model = self._models.get('gemini-2.5-flash')
|
|
1599
|
+
if model:
|
|
1600
|
+
logger.info(f"Fallback: '{name}' -> 'gemini-2.5-flash'")
|
|
1601
|
+
if not model:
|
|
1602
|
+
# Final gemini fallback: 2.5-flash (most stable, best price-performance)
|
|
1603
|
+
model = self._models.get('gemini-2.5-flash')
|
|
1604
|
+
if model:
|
|
1605
|
+
logger.info(f"Fallback: '{name}' -> 'gemini-2.5-flash' (default)")
|
|
1606
|
+
# DeepSeek variants - try OpenRouter version first (better tool calling)
|
|
1607
|
+
# then fall back to direct DeepSeek client
|
|
1608
|
+
elif 'deepseek' in model_lower:
|
|
1609
|
+
# Check if user explicitly wants OpenRouter version
|
|
1610
|
+
if 'openrouter' in model_lower or 'or-' in model_lower:
|
|
1611
|
+
model = self._models.get('deepseek/deepseek-chat')
|
|
1612
|
+
if model:
|
|
1613
|
+
logger.info(f"Fallback: '{name}' -> 'deepseek/deepseek-chat' (OpenRouter)")
|
|
1614
|
+
else:
|
|
1615
|
+
# Try OpenRouter DeepSeek first (better tool support)
|
|
1616
|
+
model = self._models.get('deepseek/deepseek-chat')
|
|
1617
|
+
if model:
|
|
1618
|
+
logger.info(f"Fallback: '{name}' -> 'deepseek/deepseek-chat' (OpenRouter preferred)")
|
|
1619
|
+
else:
|
|
1620
|
+
# Fall back to direct DeepSeek client
|
|
1621
|
+
model = self._models.get('deepseek-chat')
|
|
1622
|
+
if model:
|
|
1623
|
+
logger.info(f"Fallback: '{name}' -> 'deepseek-chat' (direct)")
|
|
1624
|
+
# GLM / Z.AI variants fallback to z-ai/glm-5.2 (must precede the
|
|
1625
|
+
# final gpt fallback so an unknown glm id keeps GLM's metadata).
|
|
1626
|
+
elif 'glm' in model_lower or 'z-ai' in model_lower or 'zhipu' in model_lower:
|
|
1627
|
+
model = self._models.get('z-ai/glm-5.2')
|
|
1628
|
+
if model:
|
|
1629
|
+
logger.info(f"Fallback: '{name}' -> 'z-ai/glm-5.2'")
|
|
1630
|
+
# OpenRouter/Grok variants fallback to x-ai/grok-4.1-fast
|
|
1631
|
+
elif 'grok' in model_lower:
|
|
1632
|
+
model = self._models.get('x-ai/grok-4.1-fast')
|
|
1633
|
+
if model:
|
|
1634
|
+
logger.info(f"Fallback: '{name}' -> 'x-ai/grok-4.1-fast'")
|
|
1635
|
+
# Kimi variants fallback to moonshotai/kimi-k2-0905
|
|
1636
|
+
elif 'kimi' in model_lower:
|
|
1637
|
+
model = self._models.get('moonshotai/kimi-k2-0905')
|
|
1638
|
+
if model:
|
|
1639
|
+
logger.info(f"Fallback: '{name}' -> 'moonshotai/kimi-k2-0905'")
|
|
1640
|
+
# Qwen variants fallback to qwen/qwen3-235b-a22b
|
|
1641
|
+
elif 'qwen' in model_lower:
|
|
1642
|
+
model = self._models.get('qwen/qwen3-235b-a22b')
|
|
1643
|
+
if model:
|
|
1644
|
+
logger.info(f"Fallback: '{name}' -> 'qwen/qwen3-235b-a22b'")
|
|
1645
|
+
|
|
1646
|
+
# Final fallback: gpt-5.1 (default) -> gpt-4.1 -> gpt-4o
|
|
1647
|
+
if not model:
|
|
1648
|
+
model = self._models.get('gpt-5.1')
|
|
1649
|
+
if model:
|
|
1650
|
+
logger.info(f"Final fallback: '{name}' -> 'gpt-5.1' (default)")
|
|
1651
|
+
else:
|
|
1652
|
+
model = self._models.get('gpt-4.1')
|
|
1653
|
+
if model:
|
|
1654
|
+
logger.info(f"Final fallback: '{name}' -> 'gpt-4.1' (secondary)")
|
|
1655
|
+
else:
|
|
1656
|
+
model = self._models.get('gpt-4o')
|
|
1657
|
+
if model:
|
|
1658
|
+
logger.info(f"Final fallback: '{name}' -> 'gpt-4o' (last resort)")
|
|
1659
|
+
|
|
1660
|
+
return model
|
|
1661
|
+
|
|
1662
|
+
def list_models(self, provider: Optional[ModelProvider] = None,
|
|
1663
|
+
include_deprecated: bool = False) -> List[ModelConfig]:
|
|
1664
|
+
"""List all registered models, optionally filtered by provider"""
|
|
1665
|
+
models = list(self._models.values())
|
|
1666
|
+
|
|
1667
|
+
if provider:
|
|
1668
|
+
models = [m for m in models if m.provider == provider]
|
|
1669
|
+
|
|
1670
|
+
if not include_deprecated:
|
|
1671
|
+
models = [m for m in models if not m.deprecated]
|
|
1672
|
+
|
|
1673
|
+
return models
|
|
1674
|
+
|
|
1675
|
+
def get_model_names(self, provider: Optional[ModelProvider] = None,
|
|
1676
|
+
include_deprecated: bool = False) -> List[str]:
|
|
1677
|
+
"""Get list of model names"""
|
|
1678
|
+
models = self.list_models(provider, include_deprecated)
|
|
1679
|
+
return [m.name for m in models]
|
|
1680
|
+
|
|
1681
|
+
|
|
1682
|
+
# Singleton instance
|
|
1683
|
+
_registry = None
|
|
1684
|
+
|
|
1685
|
+
def get_registry() -> ModelRegistry:
|
|
1686
|
+
"""Get the singleton model registry"""
|
|
1687
|
+
global _registry
|
|
1688
|
+
if _registry is None:
|
|
1689
|
+
_registry = ModelRegistry()
|
|
1690
|
+
return _registry
|
|
1691
|
+
|
|
1692
|
+
|
|
1693
|
+
# OpenAI temperature/param handling — SSOT for the "which models reject temperature"
|
|
1694
|
+
# decision (H1). Prefix-based so new o-series/gpt-5 variants are covered automatically;
|
|
1695
|
+
# the old inline substring lists (['o1','o1-mini','o3-mini','o1-preview']) missed the
|
|
1696
|
+
# registered o3 and o4-mini models -> temperature=0.0 was sent and OpenAI 400'd them.
|
|
1697
|
+
_OPENAI_REASONING_PREFIXES = ("o1", "o3", "o4")
|
|
1698
|
+
|
|
1699
|
+
|
|
1700
|
+
def openai_reasoning_model(model: str) -> bool:
|
|
1701
|
+
"""True for OpenAI o-series reasoning models (o1/o3/o4 families). These reject
|
|
1702
|
+
``temperature``, ``parallel_tool_calls`` and ``max_tokens``."""
|
|
1703
|
+
if not model:
|
|
1704
|
+
return False
|
|
1705
|
+
m = model.lower().rsplit("/", 1)[-1]
|
|
1706
|
+
return any(m.startswith(p) for p in _OPENAI_REASONING_PREFIXES)
|
|
1707
|
+
|
|
1708
|
+
|
|
1709
|
+
def openai_omits_temperature(model: str) -> bool:
|
|
1710
|
+
"""True if the OpenAI model rejects a custom ``temperature`` and it must be omitted:
|
|
1711
|
+
the o-series reasoning models plus the gpt-5 family (default-temperature only)."""
|
|
1712
|
+
if not model:
|
|
1713
|
+
return False
|
|
1714
|
+
m = model.lower().rsplit("/", 1)[-1]
|
|
1715
|
+
return openai_reasoning_model(model) or m.startswith("gpt-5")
|
|
1716
|
+
|
|
1717
|
+
|
|
1718
|
+
def get_model_config(model_name: str) -> Optional[ModelConfig]:
|
|
1719
|
+
"""Convenience function to get model config"""
|
|
1720
|
+
return get_registry().get_model(model_name)
|
|
1721
|
+
|
|
1722
|
+
|
|
1723
|
+
def thinking_config_enabled() -> bool:
|
|
1724
|
+
"""UP-07 gate for SENDING per-model thinking params (Anthropic thinking block,
|
|
1725
|
+
DeepSeek max_cot_tokens-from-registry, OpenAI reasoning_effort).
|
|
1726
|
+
|
|
1727
|
+
Default **OFF** so the hot path is byte-identical today — enabling extended thinking
|
|
1728
|
+
is a real behavior change (Anthropic forces temperature=1 + streaming, adds reasoning
|
|
1729
|
+
cost). The budgets live in the registry as the single source of truth regardless;
|
|
1730
|
+
this flag controls whether they're applied. Enable with THINKING_CONFIG_ENABLED in
|
|
1731
|
+
{1, true, yes, on}.
|
|
1732
|
+
"""
|
|
1733
|
+
from core.env import bool_env as _bool_env
|
|
1734
|
+
return _bool_env("THINKING_CONFIG_ENABLED", False)
|
|
1735
|
+
|
|
1736
|
+
|
|
1737
|
+
def get_thinking_config(model_name: str) -> Dict[str, object]:
|
|
1738
|
+
"""Per-model reasoning config (UP-07). Empty dict => no thinking params (provider/SDK
|
|
1739
|
+
default, current behavior). Returns {"budget_tokens": int} and/or
|
|
1740
|
+
{"reasoning_effort": str} for a thinking-capable model that has them set.
|
|
1741
|
+
"""
|
|
1742
|
+
config = get_model_config(model_name)
|
|
1743
|
+
if not config or not config.capabilities.supports_thinking:
|
|
1744
|
+
return {}
|
|
1745
|
+
out: Dict[str, object] = {}
|
|
1746
|
+
budget = config.capabilities.thinking_budget_tokens
|
|
1747
|
+
effort = config.capabilities.reasoning_effort
|
|
1748
|
+
if budget:
|
|
1749
|
+
out["budget_tokens"] = budget
|
|
1750
|
+
if effort:
|
|
1751
|
+
out["reasoning_effort"] = effort
|
|
1752
|
+
return out
|
|
1753
|
+
|
|
1754
|
+
|
|
1755
|
+
def get_limits(model_name: str) -> Tuple[int, int, int]:
|
|
1756
|
+
"""Get token limits for a model
|
|
1757
|
+
|
|
1758
|
+
Returns:
|
|
1759
|
+
Tuple of (context_window, max_completion_tokens, safe_input_tokens)
|
|
1760
|
+
"""
|
|
1761
|
+
config = get_model_config(model_name)
|
|
1762
|
+
if config:
|
|
1763
|
+
return (config.context_window,
|
|
1764
|
+
config.max_completion_tokens,
|
|
1765
|
+
config.safe_input_tokens)
|
|
1766
|
+
|
|
1767
|
+
# Fallback defaults
|
|
1768
|
+
logger.warning(f"Model {model_name} not in registry, using defaults")
|
|
1769
|
+
return (128000, 16384, 111616) # GPT-4 defaults
|
|
1770
|
+
|
|
1771
|
+
|
|
1772
|
+
def register_custom_model(config: ModelConfig):
|
|
1773
|
+
"""Register a custom model configuration
|
|
1774
|
+
|
|
1775
|
+
Args:
|
|
1776
|
+
config: ModelConfig object with model details
|
|
1777
|
+
"""
|
|
1778
|
+
registry = get_registry()
|
|
1779
|
+
registry._register_model(config)
|
|
1780
|
+
logger.info(f"Registered custom model: {config.name}")
|
|
1781
|
+
|
|
1782
|
+
|
|
1783
|
+
def get_all_models(provider: Optional[ModelProvider] = None,
|
|
1784
|
+
include_deprecated: bool = False) -> List[ModelConfig]:
|
|
1785
|
+
"""Get all registered models
|
|
1786
|
+
|
|
1787
|
+
Args:
|
|
1788
|
+
provider: Optional filter by provider
|
|
1789
|
+
include_deprecated: Include deprecated models
|
|
1790
|
+
|
|
1791
|
+
Returns:
|
|
1792
|
+
List of ModelConfig objects
|
|
1793
|
+
"""
|
|
1794
|
+
registry = get_registry()
|
|
1795
|
+
return registry.list_models(provider, include_deprecated)
|
|
1796
|
+
|
|
1797
|
+
|
|
1798
|
+
def calculate_cost(model_name: str, input_tokens: int, output_tokens: int,
|
|
1799
|
+
cached_tokens: int = 0, cache_creation_tokens: int = 0) -> float:
|
|
1800
|
+
"""Calculate cost for token usage
|
|
1801
|
+
|
|
1802
|
+
Args:
|
|
1803
|
+
model_name: Name of the model
|
|
1804
|
+
input_tokens: Number of input tokens (INCLUDES cached + cache-creation tokens;
|
|
1805
|
+
Anthropic folds cache reads/writes back into input before calling here)
|
|
1806
|
+
output_tokens: Number of output tokens
|
|
1807
|
+
cached_tokens: Number of cached input tokens (reads, discounted)
|
|
1808
|
+
cache_creation_tokens: Number of cache-WRITE tokens (G3: Anthropic 1.25x)
|
|
1809
|
+
|
|
1810
|
+
Returns:
|
|
1811
|
+
Total cost in USD
|
|
1812
|
+
"""
|
|
1813
|
+
config = get_model_config(model_name)
|
|
1814
|
+
if not config or not config.pricing:
|
|
1815
|
+
logger.warning(f"No pricing info for {model_name}")
|
|
1816
|
+
return 0.0
|
|
1817
|
+
|
|
1818
|
+
pricing = config.pricing
|
|
1819
|
+
|
|
1820
|
+
# Regular input = everything that is neither a cache read nor a cache write.
|
|
1821
|
+
regular_input_tokens = input_tokens - cached_tokens - cache_creation_tokens
|
|
1822
|
+
if regular_input_tokens < 0:
|
|
1823
|
+
# Defensive: never let a mis-reported split produce negative input.
|
|
1824
|
+
regular_input_tokens = 0
|
|
1825
|
+
input_cost = (regular_input_tokens / 1_000_000) * pricing.input_price
|
|
1826
|
+
|
|
1827
|
+
# Add cached input cost if applicable
|
|
1828
|
+
if cached_tokens > 0 and pricing.cached_input_price is not None:
|
|
1829
|
+
input_cost += (cached_tokens / 1_000_000) * pricing.cached_input_price
|
|
1830
|
+
|
|
1831
|
+
# G3: cache-WRITE (creation) tokens billed at cache_write_price when the provider
|
|
1832
|
+
# surcharges them (Anthropic 1.25x); otherwise at plain input price (no surcharge).
|
|
1833
|
+
if cache_creation_tokens > 0:
|
|
1834
|
+
write_price = pricing.cache_write_price if pricing.cache_write_price is not None else pricing.input_price
|
|
1835
|
+
input_cost += (cache_creation_tokens / 1_000_000) * write_price
|
|
1836
|
+
|
|
1837
|
+
# Calculate output cost
|
|
1838
|
+
output_cost = (output_tokens / 1_000_000) * pricing.output_price
|
|
1839
|
+
|
|
1840
|
+
return input_cost + output_cost
|
|
1841
|
+
|
|
1842
|
+
|
|
1843
|
+
# ---------------------------------------------------------------------------
|
|
1844
|
+
# PROVIDER_CONFIG — single source of truth for provider→client mapping
|
|
1845
|
+
# ---------------------------------------------------------------------------
|
|
1846
|
+
# Maps the canonical provider string (same strings used throughout the agent
|
|
1847
|
+
# stack) to a lightweight record describing which client class to instantiate
|
|
1848
|
+
# and whether the provider participates in the automatic fallback hierarchy.
|
|
1849
|
+
#
|
|
1850
|
+
# Rules:
|
|
1851
|
+
# fallback_eligible=True → provider is in LLMManager.FALLBACK_HIERARCHY
|
|
1852
|
+
# fallback_eligible=False → provider is NOT in the fallback hierarchy;
|
|
1853
|
+
# can still be constructed explicitly (e.g. deepseek
|
|
1854
|
+
# is excluded because its direct client has broken
|
|
1855
|
+
# tool calling — use OpenRouter's DeepSeek instead)
|
|
1856
|
+
#
|
|
1857
|
+
# Client classes are imported lazily inside the record factory to avoid
|
|
1858
|
+
# circular imports at module load time.
|
|
1859
|
+
# ---------------------------------------------------------------------------
|
|
1860
|
+
|
|
1861
|
+
from dataclasses import dataclass as _dataclass
|
|
1862
|
+
from typing import Type as _Type
|
|
1863
|
+
|
|
1864
|
+
|
|
1865
|
+
@_dataclass(frozen=True)
|
|
1866
|
+
class _ProviderEntry:
|
|
1867
|
+
"""Metadata for one LLM provider."""
|
|
1868
|
+
# String used throughout the agent stack — matches PROVIDER_CANONICAL_NAMES
|
|
1869
|
+
provider: str
|
|
1870
|
+
# Uninstantiated client class (lazy import avoids circular deps at load)
|
|
1871
|
+
client_class_name: str # e.g. "AnthropicClient" — for documentation
|
|
1872
|
+
# Whether this provider participates in LLMManager.FALLBACK_HIERARCHY.
|
|
1873
|
+
# NOTE: deepseek=False is INTENTIONAL (direct client has broken tool calling).
|
|
1874
|
+
fallback_eligible: bool
|
|
1875
|
+
|
|
1876
|
+
|
|
1877
|
+
def _build_provider_config() -> "Dict[str, _ProviderEntry]":
|
|
1878
|
+
"""Build PROVIDER_CONFIG dict, importing client classes at call time."""
|
|
1879
|
+
# Local imports to avoid circular dependency at module level.
|
|
1880
|
+
from modules.llm.anthropic_client import AnthropicClient
|
|
1881
|
+
from modules.llm.openai_client import OpenAIClient
|
|
1882
|
+
from modules.llm.deepseek_client import DeepSeekClient
|
|
1883
|
+
from modules.llm.gemini_client import GeminiClient
|
|
1884
|
+
from modules.llm.openrouter_client import OpenRouterClient
|
|
1885
|
+
from modules.llm.nvidia_client import NvidiaClient
|
|
1886
|
+
|
|
1887
|
+
return {
|
|
1888
|
+
"openai": _ProviderEntry("openai", "OpenAIClient", fallback_eligible=True),
|
|
1889
|
+
"anthropic": _ProviderEntry("anthropic", "AnthropicClient", fallback_eligible=True),
|
|
1890
|
+
# deepseek: direct client DISABLED from fallback (tool calling broken);
|
|
1891
|
+
# use OpenRouter's DeepSeek endpoint instead. Still constructable explicitly.
|
|
1892
|
+
"deepseek": _ProviderEntry("deepseek", "DeepSeekClient", fallback_eligible=False),
|
|
1893
|
+
"gemini": _ProviderEntry("gemini", "GeminiClient", fallback_eligible=True),
|
|
1894
|
+
"openrouter": _ProviderEntry("openrouter", "OpenRouterClient", fallback_eligible=True),
|
|
1895
|
+
# nvidia NIM: not in fallback hierarchy (niche, free-tier rate-limits);
|
|
1896
|
+
# constructable explicitly via 'nvidia' provider string.
|
|
1897
|
+
"nvidia": _ProviderEntry("nvidia", "NvidiaClient", fallback_eligible=False),
|
|
1898
|
+
}
|
|
1899
|
+
|
|
1900
|
+
|
|
1901
|
+
class _LazyProviderConfig:
|
|
1902
|
+
"""Proxy that builds PROVIDER_CONFIG on first access to avoid circular imports."""
|
|
1903
|
+
|
|
1904
|
+
def __init__(self) -> None:
|
|
1905
|
+
self._config: "Optional[Dict[str, _ProviderEntry]]" = None
|
|
1906
|
+
|
|
1907
|
+
def _ensure(self) -> "Dict[str, _ProviderEntry]":
|
|
1908
|
+
if self._config is None:
|
|
1909
|
+
self._config = _build_provider_config()
|
|
1910
|
+
return self._config
|
|
1911
|
+
|
|
1912
|
+
# dict-like interface
|
|
1913
|
+
def __getitem__(self, key: str) -> _ProviderEntry:
|
|
1914
|
+
return self._ensure()[key]
|
|
1915
|
+
|
|
1916
|
+
def __contains__(self, key: object) -> bool:
|
|
1917
|
+
return key in self._ensure()
|
|
1918
|
+
|
|
1919
|
+
def keys(self):
|
|
1920
|
+
return self._ensure().keys()
|
|
1921
|
+
|
|
1922
|
+
def values(self):
|
|
1923
|
+
return self._ensure().values()
|
|
1924
|
+
|
|
1925
|
+
def items(self):
|
|
1926
|
+
return self._ensure().items()
|
|
1927
|
+
|
|
1928
|
+
def get(self, key: str, default=None):
|
|
1929
|
+
return self._ensure().get(key, default)
|
|
1930
|
+
|
|
1931
|
+
|
|
1932
|
+
#: Single source of truth for provider → client-class + fallback eligibility.
|
|
1933
|
+
#: Use PROVIDER_CONFIG[provider_str] throughout the LLM subsystem instead of
|
|
1934
|
+
#: maintaining per-file client maps.
|
|
1935
|
+
PROVIDER_CONFIG = _LazyProviderConfig()
|