stulzq / azure-openai-proxy

Azure OpenAI Service Proxy. Convert OpenAI official API request to Azure OpenAI API request. Support GPT-4,Embeddings,Langchain. Adapter from OpenAI to Azure OpenAI.
Apache License 2.0
1.33k stars 192 forks source link

Require support DALL-E model #36

Open shixinyu opened 1 year ago

shixinyu commented 1 year ago

Greeting, Please consider add support DALL-E and in Azure OpenAI, the API route will be : https://xxx.openai.azure.com/openai/images/generations:submit?api-version=2023-06-01-preview

stulzq commented 1 year ago

Is there an API documentation?

stulzq commented 1 year ago

22

shixinyu commented 1 year ago

import requests import time import os api_base = 'https://aceplaying.openai.azure.com/' api_key = os.getenv("OPENAI_API_KEY") api_version = '2023-06-01-preview' url = "{}openai/images/generations:submit?api-version={}".format(api_base, api_version) headers= { "api-key": api_key, "Content-Type": "application/json" } body = { "prompt": "USER_PROMPT_GOES_HERE", "n": 2, "resolution": "1024x1024" } submission = requests.post(url, headers=headers, json=body) operation_location = submission.headers['Operation-Location'] retry_after = submission.headers['Retry-after'] status = "" while (status != "Succeeded"): time.sleep(int(retry_after)) response = requests.get(operation_location, headers=headers) status = response.json()['status'] image_url = response.json()['result']['contentUrl']

Just saw it from Azure Portal, does it help?

stulzq commented 1 year ago

This is not a valid API document, and I cannot rely on it to complete the task. I have studied the differences between OpenAI's DALLE API and Azure's preview API previously, and they are quite significant, making it impossible to act as a proxy.

shixinyu commented 1 year ago

Alright, thank you for your working. Let's wait for MS release full DALLE API.

stulzq commented 1 year ago

Alright, thank you for your working. Let's wait for MS release full DALLE API.

ok