Skip to main content

What This Example Shows

  • How to point a single agent at Claude Opus 4.8
  • How to run a hierarchical multi-agent swarm on Opus 4.8
  • The correct model name to use (anthropic/claude-opus-4-8)
  • Why you should omit temperature for this model
Claude Opus 4.8 is Anthropic’s most capable reasoning model. It is wired into every multi-agent primitive on the Swarms platform — sequential workflows, hierarchical swarms, agent rearrange, group chats, mixture-of-agents, and more. Switching is a one-line change in your agent config.
Claude Opus 4.8 has deprecated the temperature parameter. Do not pass temperature in your agent_config for this model — the Swarms API will omit it automatically when the field is unset, and the provider’s own default will apply. Setting temperature to a number will be rejected by Anthropic with a 400.

Step 1: Get Your API Key

  1. Visit https://swarms.world/platform/api-keys
  2. Sign in or create an account
  3. Generate a new API key
  4. Set it as an environment variable:

Step 2: Install the Swarms Python Client

Single Agent on Claude Opus 4.8

A minimal single-agent call. Note the model_name is the only thing that changes from any of your existing agent configs — temperature is intentionally absent.
What changed from a typical agent call:

Multi-Agent Swarm on Claude Opus 4.8

The same model name plugs into every multi-agent architecture. This example uses a HierarchicalSwarm where an auto-generated director coordinates two worker analysts — one for ETFs, one for individual stocks.
For HierarchicalSwarm, you only need to define the worker agents — the director is automatically created and orchestrated by the framework. The director routes the task to each worker, collects their outputs, and synthesizes a final response.

Using Opus 4.8 in Other Swarm Types

Every other swarm architecture takes the same model_name. Drop "model_name": "anthropic/claude-opus-4-8" into any agent inside any of these swarm configs:
  • SequentialWorkflow
  • ConcurrentWorkflow
  • AgentRearrange
  • MixtureOfAgents
  • GroupChat
  • MajorityVoting
  • CouncilAsAJudge
  • MultiAgentRouter
  • HeavySwarm
  • LLMCouncil
  • DebateWithJudge
  • BatchedGridWorkflow
  • RoundRobin
  • PlannerWorkerSwarm
  • auto

Common Pitfalls

You set temperature in your agent_config. Remove the field entirely — the Swarms API will then omit it from the upstream Anthropic call. If you have legacy code that always sends a float, set it to None and rely on the Swarms API to strip it.
Use HierarchicalSwarm (correctly spelled). Earlier versions of the API accepted the misspelled HiearchicalSwarm; the current schema only accepts the correct spelling.
The Swarms API bills token usage at the same flat rate for every model — 6.50permillioninputtokensand6.50 per million input tokens and 18.50 per million output tokens. See the pricing page for current rates.

Next Steps