Skip to content

Quick Start

Blades is a multimodal AI Agent framework based on the Go language, supporting custom models, tools, memory, middleware, etc., suitable for multi-turn dialogue, chain-of-thought reasoning, and structured output scenarios.

Ensure you have Go 1.24+ 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

Prerequisites

Before running, you need to configure environment variables for the model side (different ModelProvider variable names may vary; the key is to ensure the API Key and Base URL are available):

  • OPENAI_BASE_URL
  • OPENAI_API_KEY
  • OPENAI_MODEL

Below 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() {
// Configure OpenAI API key and base URL using environment variables:
model := openai.NewModel(os.Getenv("OPENAI_MODEL"), openai.Config{
APIKey: os.Getenv("OPENAI_API_KEY"),
})
agent, err := blades.NewAgent(
"Blades Agent",
blades.WithModel(model),
blades.WithInstruction("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 switch to 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
ProviderModelsCompatibility
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 various functional agents such as models, tools, and memory
ToolExternal capability plugins (e.g., calling APIs, querying databases)
MemoryConversation memory management, supporting multi-turn context
MiddlewareMiddleware mechanism for cross-cutting concerns such as logging, rate limiting, and authentication
ModelProviderModel adapter (e.g., OpenAI, DeepSeek), providing a unified calling interface