If by “ChatGPT code” you mean the actual source code that powers ChatGPT from OpenAI—that isn’t open-source and can’t be downloaded.
But you have great options to run ChatGPT-like systems locally or via APIs:
Options you can download/use
1) Use OpenAI’s API (official way)
You don’t download ChatGPT, you call it via API.
pip install openai
from openai import OpenAI
client = OpenAI()
resp = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role":"user","content":"Hello"}]
)
print(resp.choices[0].message.content)
2) Run open-source LLMs locally (free to download)
These are “ChatGPT-like” models you can run on your PC:
- Ollama (easiest way to run models locally)
- Download: https://ollama.com
- After install:
ollama run llama3 # or: ollama pull mistral ollama run mistral ollama pull qwen2 ollama run qwen2 ollama pull phi3 ollama run phi3
- LM Studio (GUI app for Windows/Mac/Linux)
- Download: https://lmstudio.ai
- text-generation-webui (powerful web UI)
Popular open models to try: Llama 3, Mistral/Mixtral, Qwen2, Phi-3, Gemma, DeepSeek-R1 (reasoning).
3) Open-source “ChatGPT-style” UIs (if you want the chat app feel)
- Open WebUI: https://github.com/open-webui/open-webui
Works with Ollama; one-click Docker:docker run -d -p 3000:8080 --name openwebui --restart unless-stopped \ -e OLLAMA_BASE_URL=http://host.docker.internal:11434 \ ghcr.io/open-webui/open-webui:main
- Chatbot UI: https://github.com/mckaywrigley/chatbot-ui
- LibreChat: https://github.com/danny-avila/LibreChat