> ## Documentation Index
> Fetch the complete documentation index at: https://docs.instructorphp.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Custom prompts

## Overview

In case you want to take control over the prompts sent by Instructor
to LLM for different modes, you can use the `prompt` parameter in the
`request()` or `create()` methods.

It will override the default Instructor prompts, allowing you to fully
customize how LLM is instructed to process the input.

## Example

````php theme={null}
<?php
require 'examples/boot.php';

use Cognesy\Http\Events\HttpRequestSent;
use Cognesy\Instructor\StructuredOutput;
use Cognesy\Instructor\StructuredOutputRuntime;
use Cognesy\Instructor\Enums\OutputMode;
use Cognesy\Polyglot\Inference\LLMProvider;

class User {
    public int $age;
    public string $name;
}

$provider = LLMProvider::using('openai');
$toolsRuntime = StructuredOutputRuntime::fromProvider($provider)->withOutputMode(OutputMode::Tools);
$jsonRuntime = StructuredOutputRuntime::fromProvider($provider)->withOutputMode(OutputMode::Json);
$mdJsonRuntime = StructuredOutputRuntime::fromProvider($provider)->withOutputMode(OutputMode::MdJson);

print("\n# Request for OutputMode::Tools:\n\n");
$toolsRuntime->onEvent(HttpRequestSent::class, fn(HttpRequestSent $event) => dump($event));
$user = (new StructuredOutput($toolsRuntime))
    ->with(
        messages: "Our user Jason is 25 years old.",
        responseModel: User::class,
        prompt: "\nYour task is to extract correct and accurate data from the messages using provided tools.\n",
    )->get();
echo "\nRESPONSE:\n";
dump($user);
assert($user->name === 'Jason');
assert($user->age === 25);

print("\n# Request for OutputMode::Json:\n\n");
$jsonRuntime->onEvent(HttpRequestSent::class, fn(HttpRequestSent $event) => dump($event));
$user = (new StructuredOutput($jsonRuntime))
    ->with(
        messages: "Our user Jason is 25 years old.",
        responseModel: User::class,
        prompt: "\nYour task is to respond correctly with JSON object. Response must follow JSONSchema:\n<|json_schema|>\n",
    )->get();
echo "\nRESPONSE:\n";
dump($user);
assert($user->name === 'Jason');
assert($user->age === 25);

print("\n# Request for OutputMode::MdJson:\n\n");
$mdJsonRuntime->onEvent(HttpRequestSent::class, fn(HttpRequestSent $event) => dump($event));
$user = (new StructuredOutput($mdJsonRuntime))
    ->with(
        messages: "Our user Jason is 25 years old.",
        responseModel: User::class,
        prompt: "\nYour task is to respond correctly with strict JSON object containing extracted data within a ```json {} ``` codeblock. Object must validate against this JSONSchema:\n<|json_schema|>\n",
    )->get();
echo "\nRESPONSE:\n";
dump($user);
assert($user->name === 'Jason');
assert($user->age === 25);

?>
````
