close
Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

README.md

Open AI Example

Use Expo API Routes to securely interact with the OpenAI API.

Launch your own

Launch with Expo

Structure

  • app/api/generate+api.ts: Expo API Route that interacts with the OpenAI API.
  • app/index.tsx: Screen that uses the API Route to prompt the user and display results.
  • .env: The environment variable file with references to your secret OpenAI API key.

🚀 How to use

npx create-expo-app -e with-openai

Replace OPENAI_API_KEY=YOUR_KEY in .env with your OpenAI API key.

Replace origin in the app.json with the URL to your production API Routes domain. This enables relative fetch requests.

{
  "expo": {
    "plugins": [
      [
        "expo-router",
        {
          "origin": "https://my-expo-website.com"
        }
      ]
    ]
  }
}

Ensure you upload your environment variables to wherever you host the web app and API Routes.

Deploy

Deploy on all platforms with Expo Application Services (EAS).

  • Deploy the website: npx eas-cli deployLearn more
  • Deploy on iOS and Android using: npx eas-cli buildLearn more

📝 Notes