Skip to content

Latest commit

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..

README.md

LocalStack OpenAI Extension

GitHub license Python version Build Status

This is a LocalStack extension that allows you to mock the OpenAI API for testing and development purposes. It provides a convenient way to interact with a mock OpenAI service locally using LocalStack.

Installation

You can install this extension directly using the LocalStack extension manager:

localstack extensions install localstack-extension-openai

Using

Once installed, you can access the OpenAI Mock API through localhost:4510/v1.

Example

import openai
openai.organization = "org-test"
openai.api_key = "test"
openai.api_base = "http://localhost:4510/v1"

completion = openai.ChatCompletion.create(
    model="gpt-3.5-turbo",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Hello!"}
    ]
)
print(completion.choices)

Coverage

  • Chat completion
  • Engines Listing
  • Transcribe
  • Translate
  • Generate Image URL
  • Generate Image Base64
  • Embeddings
  • Fine Tuning
  • Files
  • Moderations

Authors

Cristopher Pinzon cristopher.pinzon@localstack.cloud

Licensing

  • The extension code is licensed under the Apache 2.0 License

Thank you for using the LocalStack OpenAI Extension!