File size: 435 Bytes
d0906b5
 
 
 
 
 
bb43b4f
d0906b5
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from fastapi import FastAPI
import openai

app = FastAPI()

# Set up OpenAI API key
openai.api_key = ""

@app.post("/generate")
def generate_text(prompt: str):
    response = openai.Completion.create(
        engine="gpt-4",  # Replace with the GPT-4 engine when available
        prompt=prompt,
        max_tokens=1024,
        temperature=0.7,
    )
    return response.choices[0].text

# Run the app with `uvicorn main:app --reload`