Service authoring

From VectorSpaceLab/AREX-Skill · View interactive version

Service authoring is an AI agent skill from the GitHub repository VectorSpaceLab/AREX-Skill. Author BentoML services and APIs with the current class-based SDK, including service decorators, API/task endpoints, IO specs, batching, dependencies, lifecycle hooks, ASGI/Gradio/WebSocket/streaming integrations, GPU/runtime hints, and service-loading checks.

How to use this skill

Skill file

BentoML Service Authoring

Use this sub-skill when creating or debugging service.py and other BentoML service modules. It focuses on Python SDK authoring, not Bento packaging, model-store import mechanics, client usage, observability, cloud deployment, or CLI operations.

Route The Work

Authoring Checklist

  1. Put the service in an importable module, usually service.py, and assign the decorated class at module scope.
  2. Decorate a class with @bentoml.service or @bentoml.service(...); default service name is the class name.
  3. Keep heavyweight framework imports in __init__, lifecycle hooks, or with bentoml.importing(): if they may be absent during tooling/import-only phases.
  4. Define public endpoints with @bentoml.api or @bentoml.api(...); use @bentoml.task only for asynchronous task-queue endpoints.
  5. Add precise type hints or explicit input_spec= / output_spec= so BentoML can infer request/response schemas.
  6. Validate importability before serving or building with scripts/validate_service_target.py --target service:MyService --working-dir ..

Minimal Pattern

from __future__ import annotations

import bentoml


@bentoml.service(name="text_tools", path_prefix="/v1")
class TextTools:
    @bentoml.api(route="/echo", name="echo")
    def echo(self, text: str) -> str:
        return text

    @bentoml.api(batchable=True, max_batch_size=32, max_latency_ms=1000)
    def summarize(self, texts: list[str]) -> list[str]:
        return [text[:80] for text in texts]

Generate a fuller starter service with:

python skills/bentoml/sub-skills/service-authoring/scripts/create_minimal_service.py --output service.py --class-name TextTools

Key Decisions

Advanced Integrations

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.