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 conversations, chain-of-thought reasoning, and structured output scenarios.

Ensure you have installed Go 1.20+, then initialize your project and import Blades with the following commands:

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

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() {
// Create an Agent, specifying the model and model provider
provider := openai.NewChatProvider(
openai.WithChatOptions(
option.WithBaseURL("https://api.deepseek.com"),
option.WithAPIKey("API-YOUR-KEY"),
),
)
agent := blades.NewAgent(
"Blades Agent",
blades.WithModel("deepseek-chat"), // or gpt-5, qwen3-max, etc.
blades.WithProvider(provider),
blades.WithInstructions("You are a helpful assistant that provides detailed and accurate information."),
)
// Input prompt
prompt := blades.NewPrompt(
blades.UserMessage("What is the capital of France?"),
)
// Execute the Agent
result, err := agent.Run(context.Background(), prompt)
if err != nil {
log.Fatal(err)
}
// Output the result
log.Println(result.Text())
}

If you want to switch to another LLM 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-4, GPT-3.5, etc…Alibaba Bailian, DeepSeek
ClaudeClaude 3.7 Sonnet-
GeminiGemini 2.5 Pro-
ComponentDescription
AgentThe core of the intelligent agent, responsible for coordinating models, tools, memory, etc.
ToolExternal capability plugins (such as calling APIs, querying databases)
MemorySession memory management, supporting multi-turn context
RunnableA unified interface for all executable components (Agent, Chain, Model, etc. all implement it)
MiddlewareMiddleware mechanism for cross-cutting concerns like logging, rate limiting, authentication
ModelProviderModel adapter (e.g., OpenAI, DeepSeek), providing a unified calling interface