{"id":13429543,"url":"https://github.com/openai/openai-quickstart-python","last_synced_at":"2025-05-15T04:05:06.949Z","repository":{"id":38281057,"uuid":"433605398","full_name":"openai/openai-quickstart-python","owner":"openai","description":"Python example app from the OpenAI API quickstart tutorial","archived":false,"fork":false,"pushed_at":"2024-06-14T11:24:57.000Z","size":134,"stargazers_count":1752,"open_issues_count":1,"forks_count":1327,"subscribers_count":105,"default_branch":"master","last_synced_at":"2025-04-11T14:19:46.258Z","etag":null,"topics":["openai","openai-api"],"latest_commit_sha":null,"homepage":"https://platform.openai.com/docs/quickstart?context=python","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/openai.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-11-30T22:25:27.000Z","updated_at":"2025-04-11T06:47:50.000Z","dependencies_parsed_at":"2024-02-24T20:39:15.716Z","dependency_job_id":"651ae945-63c0-44f6-9b1c-e6faf89aafdc","html_url":"https://github.com/openai/openai-quickstart-python","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openai%2Fopenai-quickstart-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openai%2Fopenai-quickstart-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openai%2Fopenai-quickstart-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openai%2Fopenai-quickstart-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/openai","download_url":"https://codeload.github.com/openai/openai-quickstart-python/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254270643,"owners_count":22042859,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["openai","openai-api"],"created_at":"2024-07-31T02:00:41.517Z","updated_at":"2025-05-15T04:05:01.937Z","avatar_url":"https://github.com/openai.png","language":null,"funding_links":[],"categories":["official","A01_文本生成_文本对话","Others","CSS","ChatGPT Integrated Projects","Documentation and examples"],"sub_categories":["大语言对话模型及数据","Python","Documentation, lists, guides, or examples"],"readme":"# OpenAI API Quickstart - Python\n\nThis 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.\n\n## Basic request\n\nTo send your first API request with the [OpenAI Python SDK](https://github.com/openai/openai-python), make sure you have the right [dependencies installed](https://platform.openai.com/docs/quickstart?context=python) and then run the following code:\n\n```python\nfrom openai import OpenAI\nclient = OpenAI()\n\ncompletion = client.chat.completions.create(\n  model=\"gpt-3.5-turbo\",\n  messages=[\n    {\"role\": \"system\", \"content\": \"You are a helpful assistant.\"},\n    {\"role\": \"user\", \"content\": \"Hello!\"}\n  ]\n)\n\nprint(completion.choices[0].message)\n```\n\n## Setup\n\n1. If you don’t have Python installed, install it [from Python.org](https://www.python.org/downloads/).\n\n2. [Clone](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository) this repository.\n\n3. Navigate into the project directory:\n\n   ```bash\n   $ cd openai-quickstart-python\n   ```\n\n4. Create a new virtual environment:\n\n   - macOS:\n\n     ```bash\n     $ python -m venv venv\n     $ . venv/bin/activate\n     ```\n\n   - Windows:\n     ```cmd\n     \u003e python -m venv venv\n     \u003e .\\venv\\Scripts\\activate\n     ```\n\n5. Install the requirements:\n\n   ```bash\n   $ pip install -r requirements.txt\n   ```\n\n6. Make a copy of the example environment variables file:\n\n   ```bash\n   $ cp .env.example .env\n   ```\n\n7. Add your [API key](https://platform.openai.com/api-keys) to the newly created `.env` file.\n\n8. Run the app:\n\nThis step depends on the app itself. If the code uses flask (like the chat-basic example), you can run:\n\n```bash\n$ flask run\n```\n\nYou should now be able to access the app from your browser at the following URL: [http://localhost:5000](http://localhost:5000)!\n\nIf the code is just a simple Python script, you can run it with:\n\n```bash\n$ python my_file.py\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenai%2Fopenai-quickstart-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopenai%2Fopenai-quickstart-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenai%2Fopenai-quickstart-python/lists"}