AI - Getting Started with OpenAI LLM Chat Feature
AI - Getting Started with OpenAI LLM Chat Feature
Creating an OpenAI LLM Chat Bot (Including Card Registration and Payment Methods)
This guide provides a quick overview of how to register a card and set up payment for using the OpenAI API.
1. Create an OpenAI Account and Log In
- Visit the OpenAI official website.
- If you don’t have an account, sign up; if you already have an account, log in.
2. Add Payment Information
- After logging in, click on the profile icon at the top right corner and select “Manage Account.”
- In the left menu, click on “Billing.”
- Click the “Add Payment Method” button to add your payment information.
- Enter your card details and click the “Submit” button to register your payment method.
3. Payment Confirmation and Usage
- Once the payment method is registered, the fees for using the API will be automatically charged each month.
- You can check your payment history on the Billing page and download invoices if needed.
Additional Tips
- Set a Budget: Set a monthly budget to avoid unexpected overcharges.
- Set Alerts: Set up email notifications to be alerted when usage reaches a specific limit.
If Not Set Up Correctly, You May Encounter the Following Errors:
You exceeded your current quota, please check your plan and billing details. For more information on this error,...
We couldn't process your payment. If this issue persists, please contact us through our help center at https://help.openai.com.
To use the API, follow the steps below to register a card and set up payment.
How to Register a Card
Website:
https://platform.openai.com/settings/organization/billing/overview
Image:
Register your card as indicated in the menu and make a partial payment.
How to Generate an OpenAI Key
Website:
https://platform.openai.com/settings/profile?tab=api-keys
Image:
Writing Code
You can refer to the example code provided on the following reference sites.
References
https://api.python.langchain.com/en/latest/chat_models/langchain_openai.chat_models.base.ChatOpenAI.html#langchain_openai.chat_models.base.ChatOpenAI
https://platform.openai.com/docs/guides/text-generation
https://platform.openai.com/docs/api-reference/chat/create?lang=python
Example Code
# pip install -U langchain-openai
from langchain_openai import ChatOpenAI
import os
os.environ["OPENAI_API_KEY"] = "YOUR_API_KEY..."
from openai import OpenAI
api_key = os.getenv("OPENAI_API_KEY")
OpenAI.api_key = api_key
client = OpenAI()
completion = client.chat.completions.create(
model="gpt-4o-mini",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"},
{"role": "user", "content": "How is the weather today?"}
],
max_tokens=100,
temperature=0.5 # Adjusts the creativity of the response
)
print(completion.choices[0].message.content)
print(completion.choices[0].message)
This is the English translation of your original Korean article on how to get started with the OpenAI LLM chat feature.
댓글남기기