Pi Agent + OpenCode: Step-by-Step Setup with FREE Kimi K2.6 (2026 Guide)

Tony Xhepa| 00:06:06|May 7, 2026
Chapters8
Tony outlines the goal of installing and configuring the PI agent and Open Code with Cloudflare Workers AI from the terminal.

Tony Xhepa walks through installing and configuring Pi Agent and Open Code to work with Cloudflare Workers AI, using Kimi K2.6 and API tokens, all from the terminal.

Summary

Tony Xhepa demonstrates a hands-on setup for Pi Agent and Open Code, focusing on configuring Cloudflare Workers AI access. He starts by creating a Cloudflare account and locating the Workers AI REST API, then shows two installation paths via curl and a preferred curl approach. The walkthrough covers ensuring npm is installed, installing Pi Agent and Open Code, and logging in to providers with API keys or OAuth. Tony walks through generating a Cloudflare API token for Open Code and connecting it to the Workers AI, then creates a Kimi K2.6 instance and tests it with a simple “hi” prompt. He repeats the process for Pi Agent, highlighting the need for a Cloudflare account ID and proper environment variables. Finally, Tony confirms credentials are saved and demonstrates a successful small chat interaction, ending with a call to subscribe for more content. The video emphasizes step-by-step execution from scratch, including terminal commands and token management.

Key Takeaways

  • Install Pi Agent and Open Code via the recommended curl command and ensure npm is installed on your machine.
  • Create a Cloudflare account and enable Workers AI, then generate a REST API token for both Open Code and the Pi Agent workflows.
  • Connect Cloudflare Workers AI to Open Code using account ID and API key, and verify access by running a simple prompt like 'hi' with Kimi K2.6.
  • Configure a local environment variable for CLOUD_ACCOUNT_ID (Cloudflare account ID) to resolve provider authentication issues for Workers AI.
  • Log in to Pi Agent using an API key and select the Kimi K2.6 model, then save credentials and test a basic interaction.
  • Switching between Open Code and Pi Agent is done within separate configurations, ensuring API keys and tokens are kept distinct.
  • The setup process is designed to be done from scratch on a terminal, with explicit steps for token creation, environment setup, and testing.

Who Is This For?

This is essential viewing for developers who want to integrate Cloudflare Workers AI with Pi Agent and Open Code, especially those setting up from scratch in 2026 and needing a concrete, terminal-based workflow.

Notable Quotes

"Hello friends, Tony here. Welcome."
Introduction by Tony Xhepa setting the tone for a hands-on guide.
"Now you need to have npm installed in your machine."
Emphasizes a prerequisite for the installations.
"Credentials saved the users my name.py agent out JSON."
Indicates successful saving of credentials after setup.
"Let's copy this API token here and I'm going to say /connect and I'm going to connect the Cloudflare Workers AI."
Shows the step to connect Open Code to Cloudflare Workers AI.
"So let's hit enter and just enter the API key."
Describes entering an API key for Pi Agent login.

Questions This Video Answers

  • How do I install Pi Agent and Open Code with Cloudflare Workers AI step by step?
  • What tokens and account setup are required to link Open Code to Cloudflare Workers AI?
  • How can I troubleshoot 'Cloudflare account ID is required' errors during setup?
  • What is Kimi K2.6 and how do I test it after configuring Pi Agent and Open Code?
  • Which commands should I run to verify credentials are stored correctly for Cloudflare Workers AI?
Pi AgentOpen CodeCloudflare Workers AIKimi K2.6API tokensCloudflare account setupnpm installationcurl installation methodOAuth vs API keyTerminal setup
Full Transcript
Hello friends, Tony here. Welcome. In previous video, I showed you how to set up the open code application with the workers AI from the Cloudflare. And in this video, I'm going to show you step by step how you can set up your PI agent also open code. Now, because the previous video was using the application of the open code, I'm going to show you how to set up your open code from the terminal. We're going to install and then set up both of them. The PI agent also the open code with the workers AI from the Cloudflare. First we need to create an account on the Cloudflare and then go to dashboard. Here we have workers AI. We need to go to rest API and first let's go and install the PI agent and also the open code. So I'm going to copy this. You can install through curl mpm pmpnpm bun but I suggest use this curl. I'm going to open alacity here and let me just zoom it for you and then I'm going to paste. So this is going to install pi agent. Okay. I'm going to say yes. And then the same thing I'm going to do for the open code. I'm going to zoom it also this one. Now you need to have npm installed in your machine. Okay. So now pi was installed successfully. Let's install also the open code. Good. If I navigate the her directory and just if I launch here by agent. Yeah. No models available. So use / login to log into a provider via oath or API key. The same thing if I open the open code. Okay, here's the open code and we have big piggle. If I search for models for now, right now we have only big pigle. We have a popular providers which is the open code zan go openai github anthropic and google. Now let's come here and let's go and create uh workers a ai API token. I'm going to say create. And now I'm going to copy this API token here and I'm going to say /connect and I'm going to connect the Cloudflare workers AI. And here first you can see enter the your Cloudflare account ID. Here we have the account ID. Copy this account ID and paste it right here. I'm going to hit enter. Then we need the API key. So let's go and let's give it a name open code. So this one is for the open code only. And let's copy this open code and paste it here. Hit enter. And now if I say for give me K2.6 here we have. And just say hi. And yeah this is always working. Now let's see. Let's stop this one and open the PI agent. On the PI agent, we say as you can see here, use the /lo to log into provider. So, let's say / login. Hit enter. Use the subscription or use an API key. I'm going to use an API key. And we have Amazon, Anthropic, Azure, we have Cloudler, AI gateway, and also workers. So let's hit enter and just enter the API key. We can uh create another one. Let's name it PI. I'm going to name it PI anent. But you can name it what you like. I'm going to create this token. I'm going to copy this token. And now let's paste that token in here and save the API key for Cloudware Workers AI. Selected the Kimi K2.6. As you can see credentials saved the users my name.py agent out JSON. If I say hi here we have an error. So Cloudflare account ID is required for provider cloudware workers I but it's not set. So now we need so let's copy this and first let's stop here. Open the ASRC with NVIM or with Vim only and let's just say export this cloud account ID April and here we need to add that account ID which is this one here. I'm going to copy paste escape save this and source also hit enter and now if I say pi okay we have selected here as you can see kim K2.6 six from the Cloudflare and now if I say just hi yeah the user said hi and hello how can I help you okay friends that's it for this video I wanted to show you how to set up this workers AI with pi agent and also with open code from scratch now if you like such a video don't forget to subscribe like and share with your friends all the

Get daily recaps from
Tony Xhepa

AI-powered summaries delivered to your inbox. Save hours every week while staying fully informed.