Tl;dr
- To build an AI agent, you write a short program that sends a goal to a model, runs the tools the model asks for, checks the result, and stops when the goal is met.
- Build: A small agent that reads a note you already have, asks DeepSeek V4.1 Flash Uncensored to draft a reply, and stops if the note has no date.
- Time: About 20 minutes, if you already have a Venice API key.
- Languages: Python and TypeScript, both through the OpenAI SDK (OpenAI's official client library) pointed at Venice.
- Prereqs: A key, Python 3.10+ or Node.js 20+, and the official OpenAI SDK.
- Finished code: There is no separate repository. The samples below are the whole agent.
- No-code path: If you do not want to write this code, create a Mind instead of following the steps. For more no-code options, see best AI agent builders.
The model call goes to https://api.venice.ai/api/v1, which is OpenAI-compatible, meaning code written for OpenAI's API works by changing the base URL and key. Read the OpenAI migration guide for that shape and the agent guide for the surrounding setup.
Prerequisites
- A Venice API key created in your account. The samples read it from the
VENICE_API_KEYenvironment variable. Do not paste the key into source. - Python 3.10 or newer, and
pip install openai, or Node.js 20 or newer, andnpm install openai. - The model id
deepseek-v4-1-flash-uncensored. That model is Private: zero prompt retention, and Venice does not train on the inputs. - One short note you are allowed to send to the API. The sample uses a refund sentence with no customer record in it.
Set the key as an environment variable before you run either sample. On macOS and Linux:
On Windows PowerShell:
Do not commit the key. If you keep it in a .env file, add that file to .gitignore.
Step 1: Call the model once
Start with a single completion so you know the key, the base URL, and the model id work before you build on them. The system message is the rule. The user message is the note. Pick the language you use. Both versions do the same thing.
Python
TypeScript
Expected output:
A short reply printed in the terminal. The wording will differ from run to run. It should mention 30 days, and it should not add a calendar date the note never had. A Python KeyError on VENICE_API_KEY, or a 401 from the API, means the environment variable or the key is wrong. Fix that before step 2.
Why it works: The SDK speaks the OpenAI chat-completions shape. The base URL sends that shape to Venice instead of to OpenAI. The model id selects the Private default.
Step 2: How to create an AI agent that can stop
An agent is this call plus a tool and a stop. The tool here is a function in your process that returns the note. Your code decides whether the date is missing before it spends any tokens (the chunks of text a model reads and writes). That is the check, and it makes this the smallest version of an agent that still has a stop. For the full definition, see What is an AI agent?.
Python
TypeScript
Expected output:
Stopped: the note has no YYYY-MM-DD date. No model call was made.
The sample note has "30 days," not a calendar date, so the stop fires and the API is not called. Change NOTE to include a date such as 2026-11-16 if you want to see a draft. The draft still has to come from the note. Sending the email is not a tool in this program. You do that yourself.
Why it works: The stop lives in your code, not in the prompt, so nothing in the note can remove it. The model never sees the note when the check fails. That is a better default than asking the model to promise it will not invent a date.
Step 3: Put the tool result into the prompt on purpose
If the next tool is "fetch this URL," write a function that returns the page body, then pass that body as the user message. Keep the system message in your own code. Before you connect real tools, read AI agent security.
Build it yourself or hire it out
"AI agent development" often means hiring an agency to build one. You can hire someone to write the loop above, or you can do it yourself with the samples on this page. If the job is a saved configuration rather than software, skip the contract and the code and use a Mind at venice.ai/minds.
Common pitfalls and how to fix them
Pitfall: The SDK still calls api.openai.com, and you get an OpenAI auth error.
Fix: Set base_url or baseURL to https://api.venice.ai/api/v1. A key from Venice will not authenticate on OpenAI's host.
Pitfall: You put the raw key in the source file.
Fix: Read VENICE_API_KEY from the environment. Rotate any key that landed in a commit.
Pitfall: The model id is a Claude or GPT id, and you thought the call was Private.
Fix: Pass deepseek-v4-1-flash-uncensored until you mean to use Anonymous mode. Claude and GPT on Venice send the content to that provider.
Pitfall: The agent sends mail inside the first script.
Fix: Print the draft. A send tool is a separate review, with a stop that does not depend on the model agreeing.
FAQ
Is the Venice API compatible with the OpenAI SDK when I build an AI agent?
Yes, for the chat-completions format, once you set the base URL to https://api.venice.ai/api/v1. When a parameter differs, follow the migration guide. These samples use the official OpenAI Python and Node SDKs only for that compatible call.
How do I handle rate limits when I build an AI agent?
A 429 response means you have hit a rate limit. Wait a moment and retry the request, and wait a little longer after each failed attempt.
Can I stream responses from an AI agent I build?
Not in these samples, which return the full reply at once. See the API reference to add streaming.
What models can I use to build an AI agent with the Venice API?
The samples use deepseek-v4-1-flash-uncensored, the default model. Check the model library for the full list of models you can call.
How is data handled when my AI agent uses DeepSeek V4.1 Flash Uncensored?
This model runs in Private mode, so your prompt is not retained and Venice does not train on it. Even so, do not put a secret or a customer file in NOTE, the sample text these programs send to the model.
How do I create an AI agent without this code?
Create a Mind at venice.ai/minds, where you set the instructions, the model, and the tools without writing code. Try your goal in agentic chat first, so you know it works before you save the configuration.
Next steps
- AI agent integration guide
- OpenAI-compatible migration guide
- Point a coding agent at the API
- What is an AI agent?
- AI agent architecture
- Best AI agent frameworks
When you outgrow this note, use the agent guide. If you do not want to write code, create a Mind at venice.ai/minds.
Back to all posts
Venice.ai