Skip to content
AstrBot
Main Navigation HomeBlogRoadmapHTTP API

English

简体中文

English

简体中文

Toggle dark mode

Intro & DeployMessaging PlatformsAI IntegrationUsageDevelopment
Sidebar Navigation

Introduction

What is AstrBot

Community

FAQ

Deployment

Script Deployment

Desktop Client

One-click Launcher

Docker

Kubernetes

BT Panel

1Panel

Source Deployment

Other Deployments

CasaOS

Compshare GPU

Community-provided Deployment

Support Us

Messaging Platforms

Quick Start

QQ Official Bot

Websockets

Webhook

OneBot v11

WeCom Application

WeCom AI Bot

WeChat Official Account

Personal WeChat

Lark

DingTalk

Telegram

LINE

Slack

Mattermost

Misskey

Discord

KOOK

Satori

Connect Satori

Using server-satori

Community-provided

Matrix

VoceChat

AI Integration

✨ Model Providers

MiraRouter

NewAPI

ShengSuanYun

AIHubMix

PPIO Cloud

SiliconFlow

TokenPony

302.AI

DeepSeek TTS

DeepSeek STT

Ollama

LMStudio

⚙️ Agent Runners

Built-in Agent Runner

Dify

Coze

Alibaba Bailian

DeerFlow

Usage

WebUI

AstrBot CLI

Built-in Commands

Plugins

Plugins

MCP

Skills

AstrBot Built-in AI

Agent Sandbox

SubAgent Orchestration

Proactive Capabilities

Web Search

SerpApi

DeepSeek Search API

Knowledge Base

Context Compression

Custom Rules

Agent Execution Mode

Unified Webhook Mode

Development

Plugin Development

🌠 Getting Started

Minimal Example

Listen to Message Events

Send Messages

Plugin Configuration

Plugin Views

Overview

Standalone plugin page

Interactive message component

Workbench page

Shared Bridge API

Backend Web APIs

Plugin Internationalization

AI

Models

Agents

Tools

Sessions and Conversations

Other APIs

Storage

HTML to Image

Session Control

Publish Plugin

Plugin Market Specification

Versions

2026-11-25

2026-06-27

Platform Adapter Integration

AstrBot HTTP API

API Scope–Endpoint Reference

AstrBot Configuration File

Others

Diagnostics

Self-hosted HTML to Image

Open Source Summer

OSPP 2025

On this page

Models ​

Call a model to generate a reply or make a structured decision. For tool execution or conversation history, see Agents.

Chat Models ​

Getting the Chat Model ID for the Current Session ​

py
umo = event.unified_msg_origin
provider_id = await self.context.get_current_chat_provider_id(umo=umo)

Generate a reply ​

py
llm_resp = await self.context.llm_generate(
    chat_provider_id=provider_id,  # Chat model ID
    prompt="Hello, world!",
)
# print(llm_resp.completion_text) # Get the returned text

Decision Models ​

Use a decision provider to decide whether to reply or which action to take. Configure one under Providers → Decision in the WebUI, then call self.context.decision.

py
should_reply = await self.context.decision.yes_no(
    question="Should the assistant reply to this message?",
    state="I cannot log in; every request returns 500.",
    threshold=0.7,
)

strategy = await self.context.decision.choose(
    question="Which reply strategy should be used?",
    criteria={"short": "A brief reply", "detailed": "A detailed reply"},
    state="The user asks for step-by-step troubleshooting.",
)
print(strategy.choice)

yes_no() returns a bool: True when the affirmative probability meets threshold. choose() returns a DecisionChoiceAnswer; read .choice for the selected value.

state supplies context as text, a list, or a dict. Calls use the current decision provider unless you pass provider_id.

To answer multiple questions in one request, call ask({name: question}, state=...). Answers use the same keys. Import these types from astrbot.api.provider:

Question typeConfigurationAnswer type and main field
DecisionBooleanQuestioninstructions: a statement to evaluate.DecisionBooleanAnswer.probability: probability that the statement is true.
DecisionChoiceQuestioninstructions and criteria: option IDs mapped to descriptions.DecisionChoiceAnswer.choice: the selected option ID.
DecisionScoreQuestioninstructions and criteria: 2–10 level descriptions, lowest to highest.DecisionScoreAnswer.score: a possibly fractional rating from 0 to the number of levels minus 1.

An unavailable provider, failed request, or invalid response raises DecisionError. Pass default=False to yes_no() to return a fallback value for these errors.

Edit this page on GitHub

Last updated:

Pager
PreviousAI
NextAgents

Deployed on Rainyun Logo