refactor(api)!: remove the standalone API server (#6614)
This commit is contained in:
1 parent
5c72ced2fe
commit
220d5e6970
99 files changed
+240
-4133
No files matched your search
@@ -38,7 +38,6 @@ Use **Channels** in the WebUI for guided setup. These guides explain the account
|
||||
| Goal | Guide |
|
||||
|---|---|
|
||||
| Run from Python | [Python AI agent SDK](./python-ai-agent-sdk.md) |
|
||||
| Expose `/v1/chat/completions` | [OpenAI-compatible agent API](./openai-compatible-agent-api.md) |
|
||||
|
||||
## Configure and Operate
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ Continue in the WebUI from Quick Start. Start a new topic, select a practice fol
|
||||
- Choose a project folder for file work. Use [separate instances](../multiple-instances.md) when identity or long-term memory must be isolated.
|
||||
- Use `modelPresets` when you want stable names for fast, deep, local, or fallback models.
|
||||
- Keep `nanobot gateway` running for WebUI, chat apps, automations, and the WebSocket channel.
|
||||
- Use the Python SDK or OpenAI-compatible API when another program should call the agent.
|
||||
- Use the Python SDK when a Python application should call the agent.
|
||||
|
||||
## Security notes
|
||||
|
||||
|
||||
@@ -87,4 +87,3 @@ Verify in the WebUI with the new preset selected. For the manual snippet above,
|
||||
|
||||
- [Provider Cookbook: Custom OpenAI-Compatible Provider](../provider-cookbook.md#recipe-custom-openai-compatible-provider)
|
||||
- [Providers: Custom OpenAI-Compatible Endpoint](../providers.md#custom-openai-compatible-endpoint)
|
||||
- [OpenAI-Compatible Agent API](./openai-compatible-agent-api.md)
|
||||
@@ -49,8 +49,8 @@ nanobot gateway --verbose
|
||||
|
||||
## Security notes
|
||||
|
||||
- Plan ports before exposing services. Gateway health defaults to `18790`, WebUI/WebSocket defaults to `8765`, and `nanobot serve` defaults to `8900`.
|
||||
- Protect WebUI and API network listeners with their respective token or key settings. The health endpoint has no authentication; keep its published port on loopback or behind a restricted monitoring interface.
|
||||
- Plan ports before exposing services. Gateway health defaults to `18790`, and WebUI/WebSocket defaults to `8765`.
|
||||
- Protect shared WebUI access with a WebSocket token. The health endpoint has no authentication; keep its published port on loopback or behind a restricted monitoring interface.
|
||||
- Keep chat access control intentional before deploying.
|
||||
- Use Docker or Linux sandboxing when shell tools are enabled for unattended work.
|
||||
|
||||
|
||||
@@ -118,4 +118,3 @@ Authentication failures remain skipped messages. Keep the default `postActionIgn
|
||||
- [Chat Apps reference](../chat-apps.md)
|
||||
- [Secure local AI agent](./secure-local-ai-agent.md)
|
||||
- [AI Agent Memory](./ai-agent-memory.md)
|
||||
- [OpenAI-compatible agent API](./openai-compatible-agent-api.md)
|
||||
@@ -1,67 +0,0 @@
|
||||
# How to Run an OpenAI-Compatible Agent API with nanobot
|
||||
|
||||
nanobot can expose a local OpenAI-compatible endpoint behind `/v1/chat/completions`. This lets existing OpenAI-style clients talk to a tool-using nanobot agent instead of a raw model.
|
||||
|
||||
## What you will build
|
||||
|
||||
- a working nanobot agent
|
||||
- a local API server on `127.0.0.1:8900`
|
||||
- a `/v1/chat/completions` request
|
||||
- optional session isolation with `session_id`
|
||||
|
||||
## When to use this
|
||||
|
||||
Use this when an existing client, another language, or a separate process already knows how to call an OpenAI-compatible API. Use the Python SDK when you want in-process access to sessions, memory, runtime helpers, and hooks.
|
||||
|
||||
## Start from your current setup
|
||||
|
||||
If you already get replies in the WebUI, open **Settings → System**, configure the API service, and start it. Keep that gateway running; do not also start `nanobot serve` on the same port.
|
||||
|
||||
If nanobot is not configured yet, complete the [quick start](../quick-start.md) first. For a terminal-managed API using that existing config:
|
||||
|
||||
```bash
|
||||
nanobot plugins enable api
|
||||
nanobot agent -m "Hello!"
|
||||
nanobot serve
|
||||
```
|
||||
|
||||
## Make a request
|
||||
|
||||
In another terminal, call the chat endpoint. If you configured an API key, set `NANOBOT_API_KEY` to it first:
|
||||
|
||||
```bash
|
||||
curl http://127.0.0.1:8900/v1/chat/completions \
|
||||
-H "Authorization: Bearer $NANOBOT_API_KEY" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"messages": [{"role": "user", "content": "hi"}],
|
||||
"session_id": "demo"
|
||||
}'
|
||||
```
|
||||
|
||||
## Production notes
|
||||
|
||||
- Pass `session_id` to separate conversation histories. Callers still share files, memory, and tool permissions; it is not a user authorization boundary.
|
||||
- Streaming uses Server-Sent Events when `stream` is `true`. A stream without `[DONE]` is incomplete; retries can repeat tool actions. See [sessions, failures, and retries](../openai-api.md#sessions-failures-and-retries).
|
||||
- The API service returns results to its HTTP client; it does not deliver `message` tool calls to chat apps. Forward results from your application when that is needed.
|
||||
- `/v1/models` reports the fixed model surface expected by compatible clients.
|
||||
- File uploads are supported through JSON base64 or multipart form data.
|
||||
|
||||
## Security notes
|
||||
|
||||
- Local `127.0.0.1` usage does not require an API key.
|
||||
- If `api.host` is `0.0.0.0` or `::`, configure `api.apiKey` before startup.
|
||||
- Treat the API as agent access, not just model access: tools and workspace permissions still matter.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
- If `/v1/chat/completions` fails, test `nanobot agent -m "Hello!"` first.
|
||||
- If remote clients cannot connect, check `api.host`, `api.port`, firewall, and API key configuration.
|
||||
- If sessions mix together, pass a distinct, stable `session_id` for each conversation. Requests without `session_id` all share the `api:default` session. See [session behavior](../openai-api.md#sessions-failures-and-retries) before changing existing IDs.
|
||||
|
||||
## Related nanobot docs
|
||||
|
||||
- [Nanobot OpenAI-Compatible API](../openai-api.md)
|
||||
- [Python SDK](../python-sdk.md)
|
||||
- [Configuration](../configuration.md)
|
||||
- [Deployment](../deployment.md)
|
||||
@@ -12,8 +12,6 @@ This guide shows when to use the Nanobot Python SDK instead of calling a model d
|
||||
|
||||
Use the Python SDK for notebooks, evals, product backends, local scripts, workflow runners, and integrations that need direct access to agent sessions, memory, hooks, runtime state, or structured run results.
|
||||
|
||||
Use the OpenAI-compatible API instead when another language or process should call nanobot over HTTP.
|
||||
|
||||
## Before you start
|
||||
|
||||
Use an installation with a configured model that has already returned a reply. If this is your first setup, follow [Quick Start](../quick-start.md), then return here. Existing WebUI users can continue in the current instance.
|
||||
@@ -58,6 +56,5 @@ asyncio.run(main())
|
||||
## Related nanobot docs
|
||||
|
||||
- [Nanobot Python SDK](../python-sdk.md)
|
||||
- [OpenAI-Compatible API](../openai-api.md)
|
||||
- [Configuration](../configuration.md)
|
||||
- [Concepts](../concepts.md)
|
||||
@@ -47,7 +47,7 @@ Start with workspace restriction:
|
||||
- Use environment variables for provider keys, bot tokens, and mailbox passwords.
|
||||
- Use [separate instances and workspaces](../multiple-instances.md) for data that must not share memory. Project selection inside one instance does not isolate memory. Use separate OS accounts or containers for mutually untrusted users.
|
||||
- Prefer [pairing](../configuration.md#pairing) for DM-capable chat apps. Slack and Mattermost DMs default to open access: set `dm.policy` to `"allowlist"` to require approval. Configure group access separately; mention-only controls when the bot responds, not who is trusted.
|
||||
- Bind WebUI, WebSocket, and API services to localhost unless remote access is intentional. Share [WebUI access](../webui.md#sharing-access) only with trusted administrators; it has no per-user roles or private topic ownership.
|
||||
- Bind WebUI and WebSocket listeners to localhost unless remote access is intentional. Share [WebUI access](../webui.md#sharing-access) only with trusted administrators; it has no per-user roles or private topic ownership.
|
||||
|
||||
## Security notes
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
# How to Run a Self-Hosted AI Agent with nanobot
|
||||
|
||||
This guide sets up nanobot as a self-hosted AI agent runtime on your own machine or server. The result is a gateway process that can serve the WebUI, chat apps, automations, and API integrations.
|
||||
This guide sets up nanobot as a self-hosted AI agent runtime on your own machine or server. The result is a gateway process for the WebUI, chat apps, and automations.
|
||||
|
||||
## What you will build
|
||||
|
||||
- a nanobot config and workspace under your control
|
||||
- a model provider connected through `config.json`
|
||||
- a long-running `nanobot gateway`
|
||||
- optional browser, chat app, and API access
|
||||
- optional browser and chat app access
|
||||
|
||||
## When to use this
|
||||
|
||||
@@ -25,19 +25,18 @@ Self-hosting keeps the agent runtime and its state on your machine. A hosted mod
|
||||
|
||||
## Confirm the result
|
||||
|
||||
Send a message through the interface you intend to use. Check that it replies, then confirm the chosen gateway or service stays running after you close the setup terminal. Browser, chat channels, and automations use the gateway; the optional OpenAI-compatible API has its own [service setup](./openai-compatible-agent-api.md).
|
||||
Send a message through the interface you intend to use. Check that it replies, then confirm the chosen gateway or service stays running after you close the setup terminal. Browser, chat channels, and automations use the gateway.
|
||||
|
||||
## Production notes
|
||||
|
||||
- Use Docker, systemd, or a macOS LaunchAgent when the process should survive terminal exits.
|
||||
- Give every deployed instance a distinct config path, workspace path, and port set.
|
||||
- Keep secrets in environment variables and start the service from the same environment.
|
||||
- Use health checks against the gateway or API process, not chat app delivery as the only signal.
|
||||
- Use gateway health checks alongside chat app delivery.
|
||||
|
||||
## Security notes
|
||||
|
||||
- Bind local-only services to `127.0.0.1` unless you intentionally expose them.
|
||||
- Set an API key before binding the OpenAI-compatible API to a public interface.
|
||||
- Prefer pairing for DM-capable chat apps, and keep any static `allowFrom` allowlists strict.
|
||||
- Enable `tools.restrictToWorkspace`; on Linux, use the bubblewrap sandbox for shell execution.
|
||||
|
||||
@@ -45,7 +44,7 @@ Send a message through the interface you intend to use. Check that it replies, t
|
||||
|
||||
- Run `nanobot status` with the same `--config` and `--workspace` flags used by the service.
|
||||
- Run `nanobot gateway --verbose` while debugging channel startup.
|
||||
- Check port conflicts if the WebUI, WebSocket channel, or API endpoint fails to bind.
|
||||
- Check port conflicts if the WebUI or gateway health endpoint fails to bind.
|
||||
|
||||
## Related nanobot docs
|
||||
|
||||
@@ -53,4 +52,3 @@ Send a message through the interface you intend to use. Check that it replies, t
|
||||
- [Multiple Instances](../multiple-instances.md)
|
||||
- [Configuration](../configuration.md)
|
||||
- [Chat Apps](../chat-apps.md)
|
||||
- [OpenAI-Compatible API](../openai-api.md)
|
||||
Reference in new issue
Block a user