Skip to content

Quick Start

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:

Terminal window
cd your-project-name
go mod init your-project-name
go get github.com/go-kratos/blades

Here 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.com

You need to set the environment variable OPENAI_API_KEY, for example:

export OPENAI_API_KEY=your-api-key
ProviderModelCompatibility
OpenAIChatGPT, gpt-5, gpt-4, etc…qwen3-mqx、deepseek-chat
ClaudeClaude 3.7 Sonnet-
GeminiGemini 2.5 Pro-
ComponentDescription
AgentAgent interface for integrating and coordinating models, tools, memory, and other functional agents
ToolExternal capability plugins (e.g., calling APIs, querying databases)
MemoryConversation memory management, supporting multi-turn context
MiddlewareMiddleware mechanism for cross-cutting concerns like logging, rate limiting, authentication
ModelProviderModel adapter (e.g., OpenAI, DeepSeek), providing a unified calling interface