API para desarrolladores

Antes de consumir la API debes iniciar sesión en la plataforma con el correo que utilizarás y obtener el secret token en tu página de perfil.

Intercambio de token

Endpoint POST /login/tokenexchange/ (name='exchange')

Envía en el cuerpo stoken y email de un usuario registrado para recibir un session_token que se utilizará para autenticar el resto de las solicitudes.

Generar imagen

Endpoint POST /api/dev/image/ (name='dev_image')

Incluye el session_token tanto en las cookies como en los datos del formulario junto con el prompt. La respuesta contiene un task_id.

Obtener imagen

Endpoint GET /api/dev/image/

Agrega el encabezado Session-Token y el parámetro de consulta task_id. Se devolverá un JSON donde la clave es el task_id y el valor la imagen codificada en base64.

Describir imagen

Endpoint POST /describe_image/

Envía una solicitud POST con el session_token mediante cookie , junto con el cuerpo en formato application/json, incluyendo los siguientes parámetros:

El endpoint devuelve un JSON con la siguiente estructura:

 { "description": ["<imagen_en_base64>", { "role": "assistant", "content": "This image captures a breathtaking mountain range at sunset, with snow-capped peaks and a vibrant sky.\n\nIn the foreground, a vast expanse of snow-covered terrain stretches out, punctuated by scattered trees and shrubs. The snow-covered mountains in the middle ground display varying shades of white, with the sun's rays casting a warm glow on the peaks. The background features a majestic mountain range, with the sun setting behind it, creating a stunning gradient of orange, yellow, and blue hues in the sky. The overall atmosphere exudes a sense of serenity and tranquility, evoking a peaceful and idyllic setting." } ], "task_id": "MV8xNzUwNjEzMTU2LjU2NDExMjRfLmpwZw==", "credits": 54, "path_image": "...", "destination": "..." } 

Ejemplo de uso con requests en Python:

        import requests

        body = { "session_token": "b7ced25a045b6f55d5aaef14064b420b", "promp": "how many mountains are in the image", "image_base64": "<imagen_en_base64>" }
        cookies = {"session_token": "b7ced25a045b6f55d5aaef14064b420b"}
        description_response = requests.post( "https://codexaeternum.com/describe_image/", data=body ,cookies=cookies)
        if description_response.status_code == 200:
            print(description_response.keys())
            print(description_response.get("description")[1:]) #description_response.get("description")[0] -> imagen en base 64
        else:
            print(description_response.status_code)