Using DeepSeek + Python Turtle to Indirectly Generate Images: A Fun Experiment

Getting DeepSeek to write Python Turtle code as a clever workaround for image generation.
This article describes a fun experiment: since DeepSeek is a text-only model that can't generate images directly, a Bilibili creator had it write Python Turtle drawing code instead, letting the Turtle library execute the actual rendering. The approach reframes image generation as a geometric code-generation problem. Results weren't perfect — the first output was visibly misaligned — revealing the model's limitations in coordinate reasoning and spatial geometry. Even so, the experiment cleanly demonstrates the core idea behind "Tool Use" in LLMs: models don't need to do everything themselves, they just need to generate the right instructions and let external tools handle execution.
The Idea: Getting a Non-Visual DeepSeek to "Draw" Images
Large language models can write code and hold conversations, but they typically can't generate images directly. DeepSeekAd is a perfect example — it's fundamentally a text model with no image generation capability. But a Bilibili creator came up with a clever workaround: since DeepSeek can write Python code, and Python's Turtle library was designed specifically for drawing, why not combine the two to let DeepSeek "indirectly" generate images?

The core idea is straightforward: instead of having the model output pixels directly, you have it output code that draws a shape, then hand that code off to the Turtle library for execution. The final appearance of the image depends entirely on the model's understanding of drawing instruction logic and its ability to organize code.
The Method: Having the Model Write Turtle Drawing Code
Python's Turtle (turtle graphics) library is often the first visualization tool beginner programmers encounter. It draws lines and shapes by controlling a "pen" through basic actions — moving forward, turning, lifting and lowering the pen — with intuitive syntax that's well-suited for describing geometric structures in code.
The logic chain for this experiment looks like this:
- Describe the desired pattern to DeepSeek
- The model generates the corresponding Turtle drawing code
- Run the code, letting Turtle actually draw on the canvas
- Evaluate the model's "artistic" ability based on the results

What makes this approach interesting is that it reframes "image generation" as "code generation + deterministic execution." The model doesn't need to understand pixel distribution — it just needs to understand geometry: coordinates, angles, and drawing order.
Python's Turtle library was originally introduced by MIT in the Logo programming language. Its core metaphor is a "turtle" crawling across a canvas, drawing a trail via commands like
forward()(move forward),right()/left()(turn), andpenup()/pendown()(lift/lower pen). The coordinate origin defaults to the center of the canvas, with the x-axis positive to the right and the y-axis positive upward, with angles measured from due north. Because every shape must be described through either "relative movement" or "absolute coordinate jumps," the model needs a clear spatial understanding of a pattern's geometric structure when generating code — which is exactly why errors are so common in experiments like this.
The Results Aren't Perfect: The Very First Image Was Misaligned
Based on what the creator showed, the results weren't always ideal. The very first piece had obvious misalignment issues — different parts of the image didn't land where they were supposed to.

This exposes a key limitation of this approach. When drawing with code, the accuracy of the image depends entirely on the model's ability to reason about spatial coordinates and geometric relationships. Any error in coordinate calculation, turning angle, or drawing order causes the final output to go wrong. Compared to dedicated image generation models, Turtle drawing is more of a test of the model's "geometric programming" ability than its artistic expression.
What This Experiment Makes You Think About
Beyond the entertainment value, this small experiment reflects a broader and more universal idea: when a model lacks a certain direct capability, you can use a tool chain to achieve the same goal indirectly.
This aligns conceptually with the popular "Tool Use" and "Agent" paradigms — large models don't need to be good at everything. As long as they can generate correct instructions or code, they can accomplish tasks they couldn't otherwise handle by leveraging external tools. DeepSeek can't draw, but it can write drawing code, and Turtle handles the execution. This is itself a simple, hands-on demonstration of "model + tool" collaboration.
Of course, the experiment also shows that this indirect path has clear limitations:
- Output quality is constrained by the model's geometric and coordinate reasoning accuracy
- Complex patterns easily produce misalignment and proportion issues
- Controllability and visual quality are hard to guarantee compared to real text-to-image models
Tool Use refers to the mechanism by which a large language model recognizes the boundaries of its own capabilities during reasoning, and proactively generates structured instructions to call external functions, APIs, or programs. OpenAI's Function Calling, Anthropic's Tool Use API, and various Agent frameworks (such as LangChain and AutoGen) are all engineering implementations of this idea. In these frameworks, the model's role shifts from "direct answerer" to "task planner" — responsible for decomposing goals, selecting tools, and combining results, rather than directly executing every step itself. Using Turtle drawing code to make DeepSeek "paint" is precisely the most rudimentary, hands-on demonstration of this paradigm: the model outputs instructions, the Python interpreter handles execution, and each party has a clear and distinct role.
Conclusion
This is a playful technical experiment that uses DeepSeek to output Python Turtle code as a roundabout way to generate images. While the actual results showed flaws like misalignment, it vividly illustrates a key idea: letting a language model generate executable code to invoke external tools for tasks it isn't natively good at. For hobbyists interested in combining AI with programming, this makes for a fun and instructive hands-on project.
Related articles

Chain of Thought Isn't Just for AI: How Humans Can Use CoT to Improve Thinking Quality
Chain of Thought isn't just a prompt trick for large models. Starting from a Hacker News discussion, this article analyzes why CoT works for human thinking too, breaks down actionable ways to transfer it, and highlights the key differences between human CoT and machine CoT.
Cloudflare Teams Up with OpenAI: Closi…
Cloudflare Teams Up with OpenAI: Closing the Loop from Vulnerability Discovery to Defense with AI
Cloudflare uses OpenAI Daybreak to investigate security vulnerabilities and generate reviewable remediation plans, while developers use Codex to boost coding efficiency and quality.

Orca Multi-Agent Orchestration in Practice: A Guide to Parallel Collaboration with Claude and Codex
Orca is Stable AI's free open-source agent workbench supporting 34 agents like Claude Code and Codex in parallel. Learn its Git worktree isolation, multi-model orchestration, and mobile management.