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.
You can install this extension directly using the LocalStack extension manager:
localstack extensions install localstack-extension-openaiOnce installed, you can access the OpenAI Mock API through localhost:4510/v1.
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)- Chat completion
- Engines Listing
- Transcribe
- Translate
- Generate Image URL
- Generate Image Base64
- Embeddings
- Fine Tuning
- Files
- Moderations
Cristopher Pinzon cristopher.pinzon@localstack.cloud
- The extension code is licensed under the Apache 2.0 License