Build an AI Math & Physics Agent with DeepSeek v3.2

DeepSeek-V3.2 is accessible via OpenRouter. In less than 5 minutes, you can turn it into vision-enabled math and physics assistant that not only solves problems but also explains its reasoning.

In this video, the tutor solves a vector addition problem using the law of cosines, calculates the magnitude, and then verbally explains every step of the process.

What the Math & Physics Tutor Involves

Outline of the build for the AI math and physics agent with DeepSeek v3.2

Create a Starter Project and Install Dependencies

#  Create  a  new  project  with  uv  (highly  recommended)  or  pip
uv  init  deepseek-physics-tutor
cd  deepseek-physics-tutor

#  Install  Vision  Agents  +  required  plugins
uv  add  vision-agents
uv  add  "vision-agents[getstream,  openrouter,  elevenlabs,  smart-turn]"

Run the following commands in your Terminal to store the API credentials in your working environment.

OPENROUTER_API_KEY=sk-...
ELEVENLABS_API_KEY=...
STREAM_API_KEY=...
STREAM_API_SECRET=...
EXAMPLE_BASE_URL=https://pronto-staging.getstream.io

Run this Sample Code

Replace the content of the uv project's main.py with this:

"""
DeepSeek V3.2 Maths and Physics Tutor

This example demonstrates how to use the DeepSeek V3.2 model with the OpenRouter plugin with a Vision Agent.

OpenRouter provides access to multiple LLM providers through a unified API. The DeepSeek V3.2 model is a powerful LLM that is able to solve Maths and Physics problems based on what the user shows you through their camera feed.

Set OPENROUTER_API_KEY environment variables before running.
"""

import  asyncio
import  logging

from  dotenv  import  load_dotenv

from  vision_agents.core  import  User,  Agent,  cli
from  vision_agents.core.agents  import  AgentLauncher
from  vision_agents.plugins  import  (
    openrouter,
    getstream,
    elevenlabs,
    smart_turn,
)

logger  =  logging.getLogger(__name__)

load_dotenv()

async  def  create_agent(**kwargs)  ->  Agent:
    """Create the agent with OpenRouter LLM."""
    #model = "deepseek/deepseek-v3.2"  # Can also use other models like anthropic/claude-3-opus/gemini
    model  =  "deepseek/deepseek-v3.2-speciale"

    # Determine personality based on model
    if  "deepseek"  in  model.lower():
        personality  =  "Talk like a Maths and Physics tutor."
    elif  "anthropic"  in  model.lower():
        personality  =  "Talk like a robot."
    elif  "openai"  in  model.lower()  or  "gpt"  in  model.lower():
        personality  =  "Talk like a pirate."
    elif  "gemini"  in  model.lower():
        personality  =  "Talk like a cowboy."
    elif  "x-ai"  in  model.lower():
        personality  =  "Talk like a 1920s Chicago mobster."
    else:
        personality  =  "Talk casually."

    agent  =  Agent(
        edge=getstream.Edge(),
        agent_user=User(name="OpenRouter AI",  id="agent"),
        instructions=f"""
        You are an expert in Maths and Physics. You help users solve Maths and Physics problems based on what they show you through their camera feed. Always provide concise and clear instructions, and explain the step-by-step process to the user so they can understand how you arrive at the final answer.  
        {personality}
        """,
        llm=openrouter.LLM(model=model),
        tts=elevenlabs.TTS(),
        stt=elevenlabs.STT(),
        turn_detection=smart_turn.TurnDetection(
            pre_speech_buffer_ms=2000,  speech_probability_threshold=0.9
        ),
    )

    return  agent

async  def  join_call(agent:  Agent,  call_type:  str,  call_id:  str,  **kwargs)  ->  None:
    """Join the call and start the agent."""
    # Ensure the agent user is created
    await  agent.create_user()
    # Create a call
    call  =  await  agent.create_call(call_type,  call_id)

    logger.info("🤖 Starting OpenRouter Agent...")

    # Have the agent join the call/room
    with  await  agent.join(call):
        logger.info("Joining call")
        logger.info("LLM ready")

        # Open demo page for the user to join the call
        await  agent.edge.open_demo(call)

        # Wait until the call ends (don't terminate early)
        await  agent.finish()

if  __name__  ==  "__main__":

    cli(AgentLauncher(create_agent=create_agent,  join_call=join_call))

You will be automatically connected to the Math & Physics tutor for interactive problem solving.