PHP code example of yandricr / gpti-php

1. Go to this page and download the library: Download yandricr/gpti-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

yandricr / gpti-php example snippets




use gpti\...; // select model

$res = new ...();
$res->setAPI(user:"user-xxxxxxxx", secret:"nx-xxxxxxx-xxxxx-xxxxx");



use gpti\gpt;

$res = new gpt(messages:array(
    [
        "role" => "assistant",
        "content" => "Hello! How are you today?"
    ],
    [
        "role" => "user",
        "content" => "Hello, my name is Yandri."
    ],
    [
        "role" => "assistant",
        "content" => "Hello, Yandri! How are you today?"
    ]
), prompt:"Can you repeat my name?", model:"GPT-4", markdown:false);
$res->execute();

if($res->error() != null){
    print(json_encode($res->error()));
} else {
    print(json_encode($res->result()));
}



use gpti\gptv2;

$res = new gptv2(messages:array(
    [
        "role" => "assistant",
        "content" => "Hello! How are you today?"
    ],
    [
        "role" => "user",
        "content" => "Hello, my name is Yandri."
    ],
    [
        "role" => "assistant",
        "content" => "Hello, Yandri! How are you today?"
    ],
    [
        "role" => "user",
        "content" => "Can you repeat my name?"
    ]
), markdown:false, stream:false);
$res->execute();

if($res->error() != null){
    print(json_encode($res->error()));
} else {
    print(json_encode($res->result()));
}



use gpti\gptv2;

$res = new gptv2(messages:array(
    [
        "role" => "assistant",
        "content" => "Hello! How are you today?"
    ],
    [
        "role" => "user",
        "content" => "Hello, my name is Yandri."
    ],
    [
        "role" => "assistant",
        "content" => "Hello, Yandri! How are you today?"
    ],
    [
        "role" => "user",
        "content" => "Can you repeat my name?"
    ]
), markdown:false, stream:true);
$res->execute();

if($res->error() != null){
    print(json_encode($res->error()));
} else {
    foreach($res->stream() as $data){
        print(json_encode($data));
    }
}



use gpti\gptweb;

$res = new gptweb(prompt:"Are you familiar with the movie Wonka released in 2023?", markdown:false);
$res->execute();

if($res->error() != null){
    print(json_encode($res->error()));
} else {
    print(json_encode($res->result()));
}



use gpti\bing;

$res = new bing(messages:array(
    [
        "role" => "assistant",
        "content" => "Hello! How can I help you today? 😊"
    ],
    [
        "role" => "user",
        "content" => "Hi, tell me the names of the movies released in 2023."
    ],
    [
        "role" => "assistant",
        "content" => "Certainly! Here are some movies that were released in 2023:\n\n1.  **About My Father** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n2.  **The Little Mermaid** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n3.  **Fast X** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n4.  **Spider-Man: Across the Spider-Verse** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n5.  **The Machine** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n6.  **Book Club: The Next Chapter** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n7.  **Guardians of the Galaxy Vol. 3** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n8.  **John Wick: Chapter 4** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n9.  **Are You There God? It's Me, Margaret** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n10.  **Evil Dead Rise** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n11.  **The Super Mario Bros. Movie** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n12.  **Love Again** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n13.  **Kandahar** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n14.  **Dungeons & Dragons: Honor Among Thieves** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n15.  **Shin Kamen Rider** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n16.  **Knights of the Zodiac** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n17.  **The Pope's Exorcist** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n18.  **Shazam! Fury of the Gods** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n19.  **All That Breathes** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n20.  **Sailor Moon Cosmos** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n21.  **Hypnotic** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n22.  **Sound of Freedom** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n23.  **The Boogeyman** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n24.  **Chicken Run: Dawn of the Nugget** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n25.  **A Lot of Nothing** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n26.  **Followers** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n27.  **Big George Foreman** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n28.  **Asterix & Obelix: The Middle Kingdom** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n29.  **Ant-Man and the Wasp: Quantumania** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n30.  **Transformers: Rise of the Beasts** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n31.  **Follow Her** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n32.  **Prom Pact** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n33.  **God Is a Bullet** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n34.  **Still: A Michael J. Fox Movie** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n35.  **Nefarious** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n36.  **Nanny Dearest** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n37.  **Monica** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n38.  **Wild Life** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n39.  **Palm Trees and Power Lines** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n40.  **What's Love Got to Do with It?** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n41.  **Creed III** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n42.  **One True Loves** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n43.  **BlackBerry** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n44.  **Suzume** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n45.  **Rock Dog 3: Battle the Beat** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n46.  **Gridman Universe** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n47.  **Digimon Adventure 02: The Beginning** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n48.  **Woman of the Photographs** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n49.  **El Tonto** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n50.  **Seriously Red** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n\nI hope this helps! Let me know if you have any other questions."
    ],
    [
        "role" => "user",
        "content" => "Can you tell me how many movies you've told me about?"
    ]
), conversation_style:"Balanced", markdown:false, stream:false);
$res->execute();

if($res->error() != null){
    print(json_encode($res->error()));
} else {
    print(json_encode($res->result()));
}



use gpti\bing;

$res = new bing(messages:array(
    [
        "role" => "assistant",
        "content" => "Hello! How can I help you today? 😊"
    ],
    [
        "role" => "user",
        "content" => "Hi, tell me the names of the movies released in 2023."
    ],
    [
        "role" => "assistant",
        "content" => "Certainly! Here are some movies that were released in 2023:\n\n1.  **About My Father** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n2.  **The Little Mermaid** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n3.  **Fast X** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n4.  **Spider-Man: Across the Spider-Verse** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n5.  **The Machine** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n6.  **Book Club: The Next Chapter** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n7.  **Guardians of the Galaxy Vol. 3** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n8.  **John Wick: Chapter 4** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n9.  **Are You There God? It's Me, Margaret** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n10.  **Evil Dead Rise** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n11.  **The Super Mario Bros. Movie** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n12.  **Love Again** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n13.  **Kandahar** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n14.  **Dungeons & Dragons: Honor Among Thieves** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n15.  **Shin Kamen Rider** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n16.  **Knights of the Zodiac** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n17.  **The Pope's Exorcist** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n18.  **Shazam! Fury of the Gods** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n19.  **All That Breathes** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n20.  **Sailor Moon Cosmos** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n21.  **Hypnotic** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n22.  **Sound of Freedom** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n23.  **The Boogeyman** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n24.  **Chicken Run: Dawn of the Nugget** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n25.  **A Lot of Nothing** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n26.  **Followers** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n27.  **Big George Foreman** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n28.  **Asterix & Obelix: The Middle Kingdom** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n29.  **Ant-Man and the Wasp: Quantumania** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n30.  **Transformers: Rise of the Beasts** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n31.  **Follow Her** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n32.  **Prom Pact** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n33.  **God Is a Bullet** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n34.  **Still: A Michael J. Fox Movie** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n35.  **Nefarious** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n36.  **Nanny Dearest** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n37.  **Monica** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n38.  **Wild Life** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n39.  **Palm Trees and Power Lines** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n40.  **What's Love Got to Do with It?** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n41.  **Creed III** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n42.  **One True Loves** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n43.  **BlackBerry** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n44.  **Suzume** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n45.  **Rock Dog 3: Battle the Beat** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n46.  **Gridman Universe** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n47.  **Digimon Adventure 02: The Beginning** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n48.  **Woman of the Photographs** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n49.  **El Tonto** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n50.  **Seriously Red** [^1^](https://editorial.rottentomatoes.com/guide/best-movies-of-2023/)\n\nI hope this helps! Let me know if you have any other questions."
    ],
    [
        "role" => "user",
        "content" => "Can you tell me how many movies you've told me about?"
    ]
), conversation_style:"Balanced", markdown:false, stream:true);
$res->execute();

if($res->error() != null){
    print(json_encode($res->error()));
} else {
    foreach($res->stream() as $data){
        print(json_encode($data));
    }
}



use gpti\dalle;

$res = new dalle(prompt:"starry sky over the city");
$res->execute();

if($res->error() != null){
    print(json_encode($res->error()));
} else {
    print(json_encode($res->result()));
}



use gpti\dalle2;

$res = new dalle2(prompt:"An extensive green valley stretches toward imposing mountains, adorned with meadows and a winding stream. The morning sun paints the sky with warm tones, illuminating the landscape with a serenity that invites contemplation and peace.", data:array(
    "prompt_negative" => "",
    "width" => 1024,
    "height" => 1024,
    "guidance_scale" => 6
));
$res->execute();

if($res->error() != null){
    print(json_encode($res->error()));
} else {
    print(json_encode($res->result()));
}



use gpti\dalle_mini;

$res = new dalle_mini(prompt:"An extensive green valley stretches toward imposing mountains, adorned with meadows and a winding stream. The morning sun paints the sky with warm tones, illuminating the landscape with a serenity that invites contemplation and peace.");
$res->execute();

if($res->error() != null){
    print(json_encode($res->error()));
} else {
    print(json_encode($res->result()));
}



use gpti\prodia;

$res = new prodia(prompt:"Friends gathered around a bonfire in an ancient forest. Laughter, stories, and a starry sky paint an unforgettable moment of connection beneath the shadows of the mountains.", data:array(
    "model" => "absolutereality_V16.safetensors [37db0fc3]",
    "steps" => 25,
    "cfg_scale" => 7,
    "sampler" => "DPM++ 2M Karras",
    "negative_prompt" => ""
));
$res->execute();

if($res->error() != null){
    print(json_encode($res->error()));
} else {
    print(json_encode($res->result()));
}



use gpti\prodia_sd;

$res = new prodia_sd(prompt:"Friends gathered around a bonfire in an ancient forest. Laughter, stories, and a starry sky paint an unforgettable moment of connection beneath the shadows of the mountains.", data:array(
    "prompt_negative" => "",
    "model" => "absolutereality_v181.safetensors [3d9d4d2b]",
    "sampling_method" => "DPM++ 2M Karras",
    "sampling_steps" => 25,
    "width" => 512,
    "height" => 512,
    "cfg_scale" => 7
));
$res->execute();

if($res->error() != null){
    print(json_encode($res->error()));
} else {
    print(json_encode($res->result()));
}



use gpti\prodia_sdxl;

$res = new prodia_sdxl(prompt:"Friends gathered around a bonfire in an ancient forest. Laughter, stories, and a starry sky paint an unforgettable moment of connection beneath the shadows of the mountains.", data:array(
    "prompt_negative" => "",
    "model" => "sd_xl_base_1.0.safetensors [be9edd61]",
    "sampling_method" => "DPM++ 2M Karras",
    "sampling_steps" => 25,
    "width" => 1024,
    "height" => 1024,
    "cfg_scale" => 7
));
$res->execute();

if($res->error() != null){
    print(json_encode($res->error()));
} else {
    print(json_encode($res->result()));
}



use gpti\pixarta;

$res = new pixarta(prompt:"An urban landscape bathed in the sunset, where the warm tones of the sun reflect on modern buildings and the orange and purple sky. In the foreground, there's a group of friends gathered on a rooftop, laughing and enjoying the moment. Their expressions radiate joy and camaraderie as they embrace and point towards something on the horizon. The scene is enveloped in a nostalgic and emotional aura that conveys the beauty of friendship and the warmth of the sunset in a futuristic city with touches of anime style.", data:array(
    "prompt_negative" => "",
    "sampler" => "DPM-Solver",
    "image_style" => "Anime",
    "width" => 1024,
    "height" => 1024,
    "dpm_guidance_scale" => 4.5,
    "dpm_inference_steps" => 14,
    "sa_guidance_scale" => 3,
    "sa_inference_steps" => 25
));
$res->execute();

if($res->error() != null){
    print(json_encode($res->error()));
} else {
    print(json_encode($res->result()));
}



use gpti\pixartlcm;

$res = new pixartlcm(prompt:"An enchanted forest with twisted trees, a waterfall cascading into a pond of bright water lilies, and in the background, a magical tower surrounded by mythical creatures like unicorns, fairies, and dragons, under a starry sky and a giant moon.", data:array(
    "prompt_negative" => "",
    "image_style" => "Fantasy art",
    "width" => 1024,
    "height" => 1024,
    "lcm_inference_steps" => 9
));
$res->execute();

if($res->error() != null){
    print(json_encode($res->error()));
} else {
    print(json_encode($res->result()));
}



use gpti\sdv1;

$res = new sdv1(prompt:"An serene sunset landscape where a river winds through gentle hills covered in trees. The sky is tinged with warm and soft tones, with scattered clouds reflecting the last glimmers of the sun.");
$res->execute();

if($res->error() != null){
    print(json_encode($res->error()));
} else {
    print(json_encode($res->result()));
}



use gpti\sdv2;

$res = new sdv2(prompt:"An serene sunset landscape where a river winds through gentle hills covered in trees. The sky is tinged with warm and soft tones, with scattered clouds reflecting the last glimmers of the sun.", data:array(
    "prompt_negative" => "",
    "guidance_scale" => 9
));
$res->execute();

if($res->error() != null){
    print(json_encode($res->error()));
} else {
    print(json_encode($res->result()));
}



use gpti\sdxl;

$res = new sdxl(prompt:"An serene sunset landscape where a river winds through gentle hills covered in trees. The sky is tinged with warm and soft tones, with scattered clouds reflecting the last glimmers of the sun.", data:array(
    "prompt_negative" => "",
    "image_style" => "(No style)",
    "guidance_scale" => 7.5
));
$res->execute();

if($res->error() != null){
    print(json_encode($res->error()));
} else {
    print(json_encode($res->result()));
}



use gpti\emi;

$res = new emi(prompt:"A beautiful girl in a garden full of bright flowers. Her long, silky hair is adorned with flowers, and her large eyes reflect serenity. She wears a traditional kimono, smiling as she holds a delicate butterfly in her hand.");
$res->execute();

if($res->error() != null){
    print(json_encode($res->error()));
} else {
    print(json_encode($res->result()));
}



use gpti\render3d;

$res = new render3d(prompt:"In a remote corner of the galaxy, a star agonizes in its final stage of life. Its brightness, once dazzling, now fades slowly into the void of space, while a bright nebula forms around it.", data:array(
    "prompt_negative" => ""
));
$res->execute();

if($res->error() != null){
    print(json_encode($res->error()));
} else {
    print(json_encode($res->result()));
}



use gpti\pixelart;

$res = new pixelart(prompt:"A coastal city in the golden hour of the sunset. The sun slowly slips toward the horizon, tinting the sky with golden and pink hues. Skyscrapers stand out against this heavenly backdrop, reflecting the light in their glass windows. In the streets, lights flicker timidly, getting ready to illuminate the night.", data:array(
    "prompt_negative" => ""
));
$res->execute();

if($res->error() != null){
    print(json_encode($res->error()));
} else {
    print(json_encode($res->result()));
}



use gpti\animaginexl;

$res = new animaginexl(prompt:"An anime girl surrounded by cherry blossoms", data:array(
    "prompt_negative" => "",
    "quality_tags" => "Standard",
    "style_present" => "(None)",
    "width" => 1024,
    "height" => 1024,
    "strength" => 0.5,
    "upscale" => 1.5,
    "sampler" => "Euler a",
    "guidance_scale" => 7,
    "inference_steps" => 28
));
$res->execute();

if($res->error() != null){
    print(json_encode($res->error()));
} else {
    print(json_encode($res->result()));
}



use gpti\playground;

$res = new playground(prompt:"An illustration of a red owl with bright blue eye", data:array(
    "prompt_negative" => "",
    "width" => 1024,
    "height" => 1024,
    "guidance_scale" => 3
));
$res->execute();

if($res->error() != null){
    print(json_encode($res->error()));
} else {
    print(json_encode($res->result()));
}
bash
  composer