openai/openai-quickstart-python
openai/openai-quickstart-python has 1,832 GitHub stars and 1,351 forks. GitHot measured 0 stars in 24 hours and +1 in 7 days. Last checked 2026-11-13 23:04 UTC. Last push 2024-06-14.
Crecimiento de estrellas medido
- in 24h
- 0
- in 7 days
- +1
- in 15 days
- Recopilando historial
- in 1 month
- Recopilando historial
Cambios netos en períodos que se solapan, no totales diarios. Los datos no disponibles se dejan en blanco. Las estrellas indican interés, no calidad.
Acerca de
Python example app from the OpenAI API quickstart tutorial
AprendizajeREADME.md
OriginalOpenAI API Quickstart - Python
This repository hosts multiple quickstart apps for different OpenAI API endpoints (chat, assistants, etc). Check out the examples folder to try out different examples and get started using the OpenAI API.
Basic request
To send your first API request with the OpenAI Python SDK, make sure you have the right dependencies installed and then run the following code:
from openai import OpenAI
client = OpenAI()
completion = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"}
]
)
print(completion.choices[0].message)
Setup
If you don’t have Python installed, install it from Python.org.
Clone this repository.
Navigate into the project directory:
$ cd openai-quickstart-pythonCreate a new virtual environment:
macOS:
$ python -m venv venv $ . venv/bin/activateWindows:
> python -m venv venv > .\venv\Scripts\activate
Install the requirements:
$ pip install -r requirements.txtMake a copy of the example environment variables file:
$ cp .env.example .envAdd your API key to the newly created
.envfile.Run the app:
This step depends on the app itself. If the code uses flask (like the chat-basic example), you can run:
$ flask run
You should now be able to access the app from your browser at the following URL: http://localhost:5000!
If the code is just a simple Python script, you can run it with:
$ python my_file.py
Explorar proyectos relacionados
sindresorhus/awesome
😎 Listas Awesome sobre todo tipo de temas interesantes [NOTA: Las pull requests están temporalmente desactivadas hasta que tenga ocasión de ponerme al día con las existentes]
536,555 estrellasEbookFoundation/free-programming-books
:books: Libros de programación disponibles de forma gratuita
401,564 estrellasnilbuild/developer-roadmap
Hojas de ruta interactivas, guías y otros contenidos educativos para ayudar a los desarrolladores a crecer en su carrera.
371,974 estrellasvinta/awesome-python
La lista definitiva que responde a «Quiero hacer X en Python, ¿qué herramienta debería usar?».
334,615 estrellas