> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sb0.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# sb0 query

> Send queries to your deployed agent

## Command

```bash theme={null}
sb0 query "<question>"
```

## Description

Sends a query to your default agent hosted on the sb0 platform and streams the response.

## Usage

Query your deployed agent:

```bash theme={null}
sb0 query "What is the weather like today?"
```

### Expected Output

```
What is the weather like today?

I don't have access to real-time weather data. To check the current weather, I recommend:

1. Using a weather website like weather.com
2. Checking your phone's weather app
3. Using a voice assistant

Is there something else I can help you with?
```

## Quoting

Always use quotes around your question:

```bash theme={null}
# Correct
sb0 query "What is 2+2?"

# Incorrect - shell will interpret spaces
sb0 query What is 2+2?
```

## Streaming Response

The command streams the response in real-time as the agent generates it, similar to ChatGPT or Claude.ai.

## Requirements

Before using `sb0 query`:

1. **Login** - Authenticate with `sb0 login`
2. **Deploy agent** - Push at least one agent with `sb0 push`
3. **Set default** - The platform uses your most recently deployed agent by default

## Multi-line Queries

For longer queries, use heredoc syntax:

```bash theme={null}
sb0 query "$(cat <<'EOF'
Please analyze the following text and provide:
1. A summary
2. Key takeaways
3. Recommendations

Text: [Your text here]
EOF
)"
```

## Selecting a Specific Agent

If you have multiple deployed agents, you can specify which one to query:

```bash theme={null}
sb0 query "test" --agent my-agent-name
```

<Note>
  The `--agent` flag is coming soon. Currently, queries are sent to your default (most recently deployed) agent.
</Note>

## Common Issues

### Not Authenticated

```
Error: Authentication required
```

**Solution:**

```bash theme={null}
sb0 login
```

### No Agents Deployed

```
Error: No default agent found
```

**Solution:** Deploy an agent first:

```bash theme={null}
cd agent
sb0 build
sb0 push
```

### Network Errors

```
Error: Connection failed
```

**Possible solutions:**

* Check your internet connection
* Verify the platform is accessible
* Try again in a few moments

## Development Workflow

Use `sb0 query` to verify your deployed agent works correctly:

```bash theme={null}
# 1. Make changes and test locally
sb0 run --prompt "test"

# 2. Build and push updates
sb0 build
sb0 push

# 3. Test deployed version
sb0 query "test"
```

## Comparison with Local Testing

| Feature  | `sb0 run --prompt`       | `sb0 query`             |
| -------- | ------------------------ | ----------------------- |
| Location | Local Python environment | Platform (cloud)        |
| Speed    | Instant                  | Network latency         |
| Changes  | Immediate                | After `sb0 push`        |
| Purpose  | Development/testing      | Production verification |

<Tip>
  Use `sb0 run --prompt` for rapid iteration during development. Use `sb0 query` to verify your deployed agent works in production.
</Tip>

## Next Steps

* [Build agents](/v0-docs/cli/build)
* [Deploy to platform](/v0-docs/cli/push)
* [Configure platform](/v0-docs/cli/config)

## Related

* [Publishing workflow](/v0-docs/quickstart/publishing)
* [Testing locally](/v0-docs/quickstart/testing-locally)
* [Platform login](/v0-docs/cli/login)
