MCPcopy Index your code
hub / github.com/google/adk-python / get_fast_api_app

Function get_fast_api_app

src/google/adk/cli/fast_api.py:402–934  ·  view source on GitHub ↗

Constructs and returns a FastAPI application for serving ADK agents. This function orchestrates the initialization of core ADK services (Session, Artifact, Memory, and Credential) based on the provided configuration, configures the ADK Web Server, and optionally enables advanced features li

(
    *,
    agents_dir: str,
    agent_loader: BaseAgentLoader | None = None,
    session_service_uri: str | None = None,
    session_db_kwargs: Mapping[str, Any] | None = None,
    artifact_service_uri: str | None = None,
    memory_service_uri: str | None = None,
    use_local_storage: bool = True,
    eval_storage_uri: str | None = None,
    allow_origins: list[str] | None = None,
    web: bool,
    a2a: bool = False,
    task_store_uri: str | None = None,
    host: str = "127.0.0.1",
    port: int = 8000,
    url_prefix: str | None = None,
    trace_to_cloud: bool = False,
    otel_to_cloud: bool = False,
    reload_agents: bool = False,
    lifespan: Lifespan[FastAPI] | None = None,
    extra_plugins: list[str] | None = None,
    logo_text: str | None = None,
    logo_image_url: str | None = None,
    auto_create_session: bool = False,
    trigger_sources: list[Literal["pubsub", "eventarc"]] | None = None,
    default_llm_model: str | None = None,
    gemini_enterprise_app_name: str | None = None,
    express_mode: bool = False,
)

Source from the content-addressed store, hash-verified

400
401
402def get_fast_api_app(
403 *,
404 agents_dir: str,
405 agent_loader: BaseAgentLoader | None = None,
406 session_service_uri: str | None = None,
407 session_db_kwargs: Mapping[str, Any] | None = None,
408 artifact_service_uri: str | None = None,
409 memory_service_uri: str | None = None,
410 use_local_storage: bool = True,
411 eval_storage_uri: str | None = None,
412 allow_origins: list[str] | None = None,
413 web: bool,
414 a2a: bool = False,
415 task_store_uri: str | None = None,
416 host: str = "127.0.0.1",
417 port: int = 8000,
418 url_prefix: str | None = None,
419 trace_to_cloud: bool = False,
420 otel_to_cloud: bool = False,
421 reload_agents: bool = False,
422 lifespan: Lifespan[FastAPI] | None = None,
423 extra_plugins: list[str] | None = None,
424 logo_text: str | None = None,
425 logo_image_url: str | None = None,
426 auto_create_session: bool = False,
427 trigger_sources: list[Literal["pubsub", "eventarc"]] | None = None,
428 default_llm_model: str | None = None,
429 gemini_enterprise_app_name: str | None = None,
430 express_mode: bool = False,
431) -> FastAPI:
432 """Constructs and returns a FastAPI application for serving ADK agents.
433
434 This function orchestrates the initialization of core ADK services (Session,
435 Artifact, Memory, and Credential) based on the provided configuration,
436 configures the ADK Web Server, and optionally enables advanced features
437 like Agent-to-Agent (A2A) protocol support and cloud telemetry.
438
439 Args:
440 agents_dir: The root directory containing agent definitions. This path is
441 used to discover agents, load custom service registrations (via
442 services.py/yaml), and as a base for local storage.
443 agent_loader: An optional custom loader for retrieving agent instances. If
444 not provided, a default AgentLoader targeting agents_dir is used.
445 session_service_uri: A URI defining the backend for session persistence.
446 Supports schemes like 'memory://', 'sqlite://', 'postgresql://',
447 'mysql://', or 'agentengine://'. Defaults to per-agent local SQLite
448 storage if None.
449 session_db_kwargs: Optional keyword arguments for custom session service
450 initialization. These are passed to the service factory along with the
451 URI.
452 artifact_service_uri: URI for the artifact service. Uses local artifact
453 service if None.
454 memory_service_uri: URI for the memory service. Uses local memory service if
455 None.
456 use_local_storage: Whether to use local storage for session and artifacts.
457 eval_storage_uri: URI for evaluation storage. If provided, uses GCS
458 managers.
459 allow_origins: List of allowed origins for CORS.