安全运行 AI agents 与 Ollama 和 Fly.io
2026年10月13日 (英语).
兹Ollama Cloud现在工作在使用Fly.io Sprites为agents设计的全Linux计算机内部。
Sprite是一个来自Fly.io的沙盒。 每个都是一个完整的Linux虚拟机,拥有自己的磁盘,在会话间停留。 Claude Code,Codex和Gemini CLI被支持出框,并将让agents在一个沙盒中运行,以安全运行命令。
有了新的Ollama连接器,你的Sprite可以使用Ollama的云模型,如kimi-k3,glm-5.3和deepseek-v4.1-flash.
如何运作
您将您的 Ollama API 密钥添加到您的 Fly.io 组织中,Fly.io 加密后从不通过 API 返回。
当Sprite内部的代码呼叫Ollama时,它会通过一个Fly.io网关。 Sprite 调用您的密钥的网关和新增。 Sprite本身只知道网关URL和连接ID.
这意味着:
agent在Sprite中无法泄露你的钥匙。
- 新的连接器默认会阻断每个Sprite 您选择哪些访问:通过标签、名称前缀或全部访问。
- 只从Sprite里面打来
开始吧
您需要 Ollama API 键和至少一个 Sprite 键。
- 在Fly.io仪表板中,打开Sprites,然后是连接器,用你的API键添加Ollama连接器。
- 在访问配置下,选择哪个Sprite可以使用和保存。
- 点击在Sprite旁边测试可达性,以检查它能达到Ollama.
然后,从Sprite内部:
卷曲"https://api.sprites.dev/v1/gateway/ollama/<连接 id>/v1/chat/完成"\#
-H"Content-Type:应用程序/json"\?
-d'{'型号:"kimi-k3","消息":[{'作用':"用户","内容":"你好!]}}'
连接器页面显示此命令与您填写的连接ID。 没有授权信头,因为网关新增您的密钥。
Python
任何OpenAI SDK的作品。 设置网关的基数 url,并使用任何值来表示 api key:
从 openai 导入 OpenAI
客户端 = OpenAI ()
base url=“https://api.sprites.dev/v1/gateway/ollama/<连接 id>/v1”
api key=“未使用”
)
响应=客户端.chat. completes.create ()
模型=“glm-5.3”
消息=[{"作用":"用户","内容":"天空为什么是蓝色的?"}
)
打印( 答复。 choices [0]. message.content)
Ollama的本地/api/*线路也通过网关。
编码 agents
Fly.io Sprites来时的技巧告诉Claude Code,Cursor,Codex和Gemini CLI关于Ollama. 如果Sprite有访问权限,agent可以在没有任何设置的情况下使用Ollama模型。
示例:模糊测试
Fly.io有一个指南,它一起使用多个模型。 一个像Nemotron-3-nano:30b这样的小模型会写出畸形输入,一个Sprite会根据你的程序运行它们,一个像kimi-k3这样的更大的模型会看着坠机。 要切换模型,要改变模型领域。 见Ollama连接器快速启动。
感谢Fly.
本文由 AI宝盒自动抓取并翻译,版权归原作者所有;如需查看原文请点下方链接。
Run AI agents safely with Ollama and Fly.io
October 13, 2026
Ollama Cloud now works inside full Linux computers designed for agents using Fly.io Sprites.
A Sprite is a sandbox from Fly.io. Each one is a full Linux virtual machine with its own disk that stays around between sessions. Claude Code, Codex and Gemini CLI are supported out of the box and will let agents run in a sandbox to securely run commands.
With the new Ollama Connector, your Sprites can use Ollama’s cloud models like kimi-k3, glm-5.3 and deepseek-v4.1-flash.
How it works
You add your Ollama API key to your Fly.io organization, and Fly.io encrypts it and never returns it through the API.
When code inside a Sprite calls Ollama, it goes through a Fly.io gateway. The gateway checks which Sprite is calling and adds your key to the request. The Sprite itself only knows a gateway URL and a connection ID.
This means:
- An agent in a Sprite can’t leak your key.
- New connectors block every Sprite by default. You choose which ones get access: by label, by name prefix or all of them.
- Calls only work from inside a Sprite.
Get started
You’ll need an Ollama API key and at least one Sprite.
- In the Fly.io dashboard, open Sprites, then Connectors, and add an Ollama connector with your API key.
- Under Access Configuration, choose which Sprites can use it and save.
- Click Test reachability next to a Sprite to check that it can reach Ollama.
Then, from inside the Sprite:
curl "https://api.sprites.dev/v1/gateway/ollama/<connection_id>/v1/chat/completions" \
-H "Content-Type: application/json" \
-d '{"model": "kimi-k3", "messages": [{"role": "user", "content": "Hello!"}]}'
The connector page shows this command with your connection ID filled in. There’s no Authorization header because the gateway adds your key.
Python
Any OpenAI SDK works. Set base_url to the gateway and use any value for api_key:
from openai import OpenAI
client = OpenAI(
base_url="https://api.sprites.dev/v1/gateway/ollama/<connection_id>/v1",
api_key="unused",
)
response = client.chat.completions.create(
model="glm-5.3",
messages=[{"role": "user", "content": "Why is the sky blue?"}],
)
print(response.choices[0].message.content)
Ollama’s native /api/* routes work through the gateway too.
Coding agents
Fly.io Sprites come with a skill that tells Claude Code, Cursor, Codex and Gemini CLI about Ollama. If the Sprite has access, the agent can use Ollama models without any setup.
Example: fuzzing
Fly.io has a guide that uses several models together. A small model like nemotron-3-nano:30b writes malformed inputs, a Sprite runs them against your program, and a larger model like kimi-k3 looks at the crashes. To switch models, change the model field. See the Ollama Connector quickstart.
Thank you to the Fly.io team for building this with us.
Auto-fetched and translated by AI Gem Box. All rights belong to the original author.