Causes for engine not found error

Before getting on the codex waitlist I was getting an “engine not found” error when I tried to make an api call for it. After getting on the waitlist I am getting the same error. I tried spelling it “code-davinci-002” and even “code-davinci:002” but both yielded the same result.

How can I access the codex api? What do I need to do?

*NOTE: this is resolved as of 5/11/22

Hi @scottlydon18

Welcome to the OpenAI community.

Can you share more about the API call you made? Code? Endpoint? Response?

My apologies.

I am trying to recreate or re-implement OpenAI API, using the api and requests.

I am using
https://api.openai.com/v1/engines/code-davinci-002/completions
method: POST

I removed my token (for privacy purposes).

Optional<URLRequest>
  ▿ some : https://api.openai.com/v1/engines/code-davinci-002/completions
    ▿ url : Optional<URL>
      ▿ some : https://api.openai.com/v1/engines/code-davinci-002/completions
        - _url : https://api.openai.com/v1/engines/code-davinci-002/completions
    - cachePolicy : 0
    - timeoutInterval : 60.0
    - mainDocumentURL : nil
    - networkServiceType : __C.NSURLRequestNetworkServiceType
    - allowsCellularAccess : true
    ▿ httpMethod : Optional<String>
      - some : "POST"
    ▿ allHTTPHeaderFields : Optional<Dictionary<String, String>>
      ▿ some : 2 elements
        ▿ 0 : 2 elements
          - key : "Content-Type"
          - value : "application/json"
        ▿ 1 : 2 elements
          - key : "Authorization"
          - value : "Bearer sk-<myToken_removed>"
    ▿ httpBody : Optional<Data>
      ▿ some : 414 bytes
        - count : 414
        ▿ pointer : 0x00007ff464011400
          - pointerValue : 140687626540032
    - httpBodyStream : nil
    - httpShouldHandleCookies : true
    - httpShouldUsePipelining : false
    static var sqlTranslate: Self {
        .init(
            urlString: "https://api.openai.com/v1/engines/code-davinci-002/completions",
            method: .post,
            httpBody: .completionDictionary(
                prompt:
                    """
                    ### Postgres SQL tables, with their properties:
                    #
                    # Employee(id, name, department_id)
                    # Department(id, name, address)
                    # Salary_Payments(id, employee_id, amount, date)
                    #
                    ### A query to list the names of the departments which employed more than 10 employees in the last 3 months
                    SELECT
                    """
                ,
                sampling: .temperature(0),
                numberOfTokens: ...150,
                stop: ["#", ";"],
                user: nil,
                presencePenalty: 0,
                frequencyPenalty: 0,
                bestOf: nil
            )
        )
    }

It started working…
Perhaps there is a day long delay after approval for the api before it works?.. Anyway. it seems to be working.

Before working, I was getting the response discussed here: python - openai.error.InvalidRequestError: Engine not found - Stack Overflow

1 Like

Yeah that seems to be the case. Glad it works now; I was having a hard time understanding the first block of code you shared.

Cheers!