Quick Start

Quickly build a fully-featured agent application with deepseek-kit

Scaffold a Project

The fastest way to get started is using the CLI scaffolding tool:

npx create-deepseek-kit my-agent

Manual Setup

If you prefer to set up manually:

Install Dependencies

npm
pnpm
bun
yarn
npm i deepseek-kit zod dotenv

Set API Key

Get your API key at platform.deepseek.com

.env
DEEPSEEK_API_KEY=your_api_key

Build a Basic Agent

Create a simple agent that can answer questions and autonomously call tools. Let's see how to build an agent that queries the weather on its own.

agent.ts
import { createAgent, createModel, tool } from 'deepseek-kit'
import * as z from 'zod'

// First, create the model
const model = createModel({
  model: 'deepseek-v4-flash',
})

// Define a weather query tool
const getWeatherTool = tool({
  name: 'getWeather',
  description: 'Query the weather for a city',
  schema: z.object({
    city: z.string().describe('City name'),
  }),
  execute(args) {
    return `${args.city}: Sunny today, 22°C, humidity 60%.`
  },
})

// Create the agent
const agent = createAgent({
  model,
  tools: [getWeatherTool],
})

// Call the agent
const response = await agent.generate({
  prompt: 'How\'s the weather in Chongqing today?',
})

// Print the agent's response
console.log(response.text)

How It Works

When the agent receives the user's question How's the weather in Chongqing today?, the collaboration flow works as follows:

  1. Intent Understanding: The LLM analyzes the user's question and identifies it as a weather query request
  2. Tool Selection: The model determines from the registered tool list that it needs to call getWeatherTool to fetch weather data
  3. Parameter Extraction: The model extracts the city parameter city: "Chongqing" from the question
  4. Tool Execution: The framework calls getWeatherTool's execute function, which returns simulated weather data
  5. Result Integration: The model integrates the tool's returned data into a natural language response and outputs the final result

Expected Output:

Chongqing: Sunny today, 22°C, humidity 60%.