# Adding OpenAI API features into XBlocks

**URL:** <https://discuss.openedx.org/t/adding-openai-api-features-into-xblocks/11449>\
**Category:** Development\
**Tags:** how-to, blockstore\
**Created:** [October 17, 2023, 6:56pm UTC](https://discuss.openedx.org/t/adding-openai-api-features-into-xblocks/11449 "2023-10-17T18:56:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lpm0073](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.openedx.org/lpm0073/32/45_2.png) [@lpm0073](https://discuss.openedx.org/u/lpm0073)\
**Post date:** [October 17, 2023, 6:56pm UTC](https://discuss.openedx.org/t/adding-openai-api-features-into-xblocks/11449/1 "2023-10-17T18:56:42Z")

</div>

Greetings all, i created this [full stack serverless project](https://github.com/FullStackWithLawrence/aws-openai) consisting of a React app + REST API that implements all 30 example applications from the [OpenAI API documentation](https://platform.openai.com/examples). It provides a pretty good roadmap for how to build OpenAI chat features into your XBlocks. I also deployed it to my personal domain at [openai.lawrencemcdaniel.com](https://openai.lawrencemcdaniel.com/) you’d like to see how it works.

 ![Screenshot 2023-10-17 at 12.45.02 p.m.](https://us1.discourse-cdn.com/flex020/uploads/openedx/original/2X/1/12a459b4b0f5911de35f1f62de3a304dec72dd4c.jpeg)

Key React features include:

- robust, highly customizable chat features
- A component model for implementing your own highly personalized OpenAI apps
- Skinnable UI for each app
- Includes default assets for each app
- Small compact code base
- Robust error handling for non-200 response codes from the custom REST API
- Handles direct text input as well as file attachments
- Info link to the OpenAI API official code sample
- Build-deploy managed with Vite

Key backend features include:

- Built on the [OpenAI API Python Library](https://pypi.org/project/openai/)
- Customizable. [Modularized endpoints](https://github.com/FullStackWithLawrence/aws-openai/blob/main/terraform/apigateway_endpoints.tf) that only take a few lines of code each.
- Highly secure. Your OpenAI API key is stored in a local .env file, and is kept safe during development, build and deployment to production.
- Implements excellent [CloudWatch](https://aws.amazon.com/cloudwatch/) logs for Lambda as well as API Gateway
- Fully automated and [parameterized](https://github.com/FullStackWithLawrence/aws-openai/blob/main/api/terraform/terraform.tfvars) Terraform build
- well documented code plus supplemental [documentation resources](https://github.com/FullStackWithLawrence/aws-openai/blob/main/doc) as well as detailed documentation on each [URL endpoint](https://github.com/FullStackWithLawrence/aws-openai/blob/main/doc/examples/README.md).
- Low-cost [AWS serverless](https://aws.amazon.com/serverless/) implementation using [AWS API Gateway](https://aws.amazon.com/api-gateway/) and [AWS Lambda](https://aws.amazon.com/lambda/); free or nearly free in most cases
- Robust, performant and infinitely scalable
- Fast build time; usually less than 60 seconds to fully implement
- Includes both Python and Node.js Lambda examples
- Deploy https to a custom domain
- Preconfigured [Postman](https://www.postman.com/) files for testing
- includes AWS API Gateway usage policy and api key
- Full CORS configuration
