laravel-tembo lets you trigger AI coding agents from PHP

laptop screen displaying colorful code

laravel-tembo is a community-built PHP SDK that connects Laravel apps to the Tembo API. Tembo runs coding agents (Claude Code, Codex, Cursor, Amp, Opencode) in the background on your repositories and typically delivers a pull request when the job is done. This package gives Laravel developers a native way to start those agents and react when they finish.

What It Does

Install via Composer (composer require cabuz/laravel-tembo), drop your TEMBO_API_KEY into .env, and you can kick off an agent in a few lines:

$session = Tembo::sessions()->start('Fix the N+1 query on the orders page', [
    'codeRepositoryIds' => [$repositoryId],
]);

Tembo::sessions()->watch($session['id'], ['ticket_id' => $ticket->id]);

watch() dispatches a queued job that polls every 30 seconds and fires a SessionCompleted, SessionFailed, or SessionCancelled event when the agent wraps up. No worker sits blocked while the agent runs.

Key Features

  • Full API coverage: sessions, messages, agents (runs, schedules, triggers), projects, repositories, pull requests, MCP connections, skills, organizations, billing, and more. Every SDK method is tested against Tembo’s OpenAPI schema.
  • Laravel-native: uses Laravel’s HTTP client, so Http::fake() and Tembo::fake() work cleanly in your test suite.
  • Live output via WebSocket: stream what the agent is doing in real time with automatic reconnects (up to 5 retries with backoff). Requires composer require phrity/websocket.
  • Safe retries: rate-limit errors are retried on every request; server errors and dropped connections are retried only on GET requests, so a failed POST never accidentally starts the same agent twice.
  • Cursor pagination: list methods return a CursorPage with a .lazy() helper to stream all pages on demand.
  • Typed exceptions: NotFoundException, RateLimitException, AuthenticationException, and others map directly to HTTP status codes.
  • Artisan commands: php artisan tembo:check verifies your API key; php artisan tembo:run starts an agent from the terminal with optional --follow to stream live output.

️ Agents and Schedules

Beyond one-off sessions, the package supports persistent agents with cron schedules and manual runs:

$agent = Tembo::agents()->create([
    'name' => 'Dependency updater',
    'instructions' => 'Update outdated Composer packages and open a PR.',
    'repositoryIds' => [$repositoryId],
]);

Tembo::agents()->schedules()->create($agent['id'], ['cron' => '0 6 * * 1']);

$run = Tembo::agents()->run($agent['id'], ['reason' => 'Security advisory CVE-2026-1234']);

Requirements and Pricing

  • PHP 8.1 or higher
  • Laravel 10.10, 11, 12, or 13
  • A Tembo API key (created in the Tembo dashboard under Settings > API Keys)

The package is MIT licensed and free. Tembo’s own official SDK is TypeScript-only, so this fills the gap for PHP shops. The structure and method names mirror the official TypeScript SDK’s api.md for consistency.

Stay on top of AI & Automation with BizStack Newsletter
BizStack  —  Entrepreneur’s Business Stack
Logo