Blades is a multimodal AI Agent framework based on Go, supporting custom models, tools, memory, middleware, etc., suitable for multi-turn conversations, chain-of-thought reasoning, and structured output scenarios.
Ensure you have Go 1.20+ installed, then initialize your project and import Blades with the following commands:
cd your-project-namego mod init your-project-namego get github.com/go-kratos/bladesHere is a complete example of building a simple chat Agent using the OpenAI model:
package main
import ( "context" "log"
"github.com/go-kratos/blades" "github.com/go-kratos/blades/contrib/openai" "github.com/openai/openai-go/v2/option")
func main() { // set up the OpenAI provider provider := openai.NewChatProvider( openai.WithChatOptions( option.WithAPIKey("YOUR_API_KEY"), option.WithBaseURL("YOUR_BASE_URL"), ), ) // create agent agent, err := blades.NewAgent( "Blades Agent", blades.WithModel("YOUR_MODEL"), // or gpt-5, qwen3-max, etc. blades.WithProvider(provider), blades.WithInstructions("You are a helpful assistant that provides detailed and accurate information."), ) if err != nil { log.Fatal(err) } // Create a new input message input := blades.UserMessage("What is the capital of France?") // Create a new input message // Run the agent runner := blades.NewRunner(agent) result, err := runner.Run(context.Background(), input) if err != nil { log.Fatal(err) } log.Println(result.Text())}If you want to use another provider’s API, you need to set environment variables, for example:
export OPENAI_BASE_URL=https://api.deepseek.comYou need to set the environment variable OPENAI_API_KEY, for example:
export OPENAI_API_KEY=your-api-key| Provider | Model | Compatibility |
|---|---|---|
| OpenAI | ChatGPT, gpt-5, gpt-4, etc… | qwen3-mqx、deepseek-chat |
| Claude | Claude 3.7 Sonnet | - |
| Gemini | Gemini 2.5 Pro | - |
| Component | Description |
|---|---|
| Agent | Agent interface for integrating and coordinating models, tools, memory, and other functional agents |
| Tool | External capability plugins (e.g., calling APIs, querying databases) |
| Memory | Conversation memory management, supporting multi-turn context |
| Middleware | Middleware mechanism for cross-cutting concerns like logging, rate limiting, authentication |
| ModelProvider | Model adapter (e.g., OpenAI, DeepSeek), providing a unified calling interface |