中文 | English
- openai
- gemini
- groq
- claude
- cohere
- ...
To download and install Vercel CLI, run the following command:
pnpm i -g vercel
vercel login
Publish to Vercel
vercel --prod -y
# openai
https://your.proxyapi.domian/openai/
# gemini
https://your.proxyapi.domian/gemini/
# groq
https://your.proxyapi.domian/groq/
# claude
https://your.proxyapi.domian/claude/
# cohere
https://your.proxyapi.domian/cohere/
import random
import re
from openai import OpenAI
ApiKey = "sk-Qa7GFtgCspCVfVGqKhm43QFmEB1FxsFvkXNysVycCuwDv2rz"
BaseUrl = "https://your.proxyapi.domian/openai/v1"
models = [
"gpt-3.5-turbo",
"gpt-4o-mini"
]
def gentext():
client = OpenAI(api_key=ApiKey, base_url=BaseUrl)
model = random.choice(models)
try:
completion = client.chat.completions.create(
model=model,
messages=[
{
"role": "system",
"content": "You are a smart and creative novelist."
},
{
"role": "user",
"content": "As the king of fairy tales, please write a short fairy tale, the theme of the story is to always maintain a kind heart, to stimulate children's interest and imagination in learning, and to help children better understand and accept the truth and values contained in the story. Only the story content is output, and the title and others are not required."
}
],
top_p=0.7,
temperature=0.7
)
text = completion.choices[0].message.content
print(f"{model}:{re.sub(r'\n+', '', text)}")
except Exception as e:
print(f"{model}:{str(e)}\n")