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

# Strict Mode

> How to use strict mode when executing an agent

## Strict Mode

By default, if you send input that doesn't strictly match the input schema, the Logic API will try to make sense of it anyway. This improves backward compatibility: if your input shape changes over time, the Logic API will adapt instead of throwing an error.

If you want to run the agent in strict mode, which means it will error if the input data does not precisely match the input schema, you can add the query parameter `?enforceInputSchema=true` to your call.

<Note>
  Note: This only impacts input data. The output data will always match the
  output schema.
</Note>

### Examples of Strict Mode on and off

For an agent that takes an input schema of:

```json theme={null}
{
  "artistName": {
    "type": "string",
    "description": "The name of the artist."
  }
}
```

#### Strict Mode Off

Strict mode off would accept a slightly incorrect input, like `artistName` being `artist-name`

Below are examples of calling this agent with strict mode
**off**, using input that doesn't fit the schema but will still be accepted.

<CodeGroup>
  ```bash curl theme={null}
  curl -X POST 'https://api.logic.inc/v1/agents/summarize-music-artist-profile/executions'
    -H "Authorization: Bearer $LOGIC_API_TOKEN"
    -H "Content-Type: application/json"
    -d '{
          "artist-name": "Adele"
        }'
  ```

  ```bash httpie theme={null}
  http POST https://api.logic.inc/v1/agents/summarize-music-artist-profile/executions
    "Authorization:Bearer $LOGIC_API_TOKEN"
    "Content-Type:application/json"
    artist-name="Adele"
  ```

  ```python python theme={null}
  import requests
  import json

  url = "https://api.logic.inc/v1/agents/summarize-music-artist-profile/executions"
  headers = {
      "Authorization": "Bearer ls-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
      "Content-Type": "application/json"
  }
  data = {
      "artist-name": "Adele"
  }

  response = requests.post(url, headers=headers, data=json.dumps(data))
  print(response.status_code, response.text)
  ```

  ```ruby ruby theme={null}
  require 'net/http'
  require 'json'

  uri = URI('https://api.logic.inc/v1/agents/summarize-music-artist-profile/executions')
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true

  LOGIC_API_TOKEN = 'ls-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
  headers = {
    "Authorization" => "Bearer #{LOGIC_API_TOKEN}",
    "Content-Type" => "application/json"
  }
  body = { "artist-name" => "Adele" }.to_json

  request = Net::HTTP::Post.new(uri, headers)
  request.body = body

  response = http.request(request)
  puts response.code
  puts response.body
  ```

  ```javascript javascript theme={null}
  const LOGIC_API_TOKEN = "ls-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";

  fetch(
    "https://api.logic.inc/v1/agents/summarize-music-artist-profile/executions",
    {
      method: "POST",
      headers: {
        Authorization: `Bearer ${LOGIC_API_TOKEN}`,
        "Content-Type": "application/json",
      },
      body: JSON.stringify({ "artist-name": "Adele" }),
    },
  )
    .then((res) => res.text())
    .then(console.log)
    .catch(console.error);
  ```

  ```go go theme={null}
  package main

  import (
      "bytes"
      "encoding/json"
      "fmt"
      "net/http"
      "io/ioutil"
  )

  const (
      LOGIC_API_TOKEN = "ls-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  )

  func main() {
      url := "https://api.logic.inc/v1/agents/summarize-music-artist-profile/executions"

      body := map[string]string{
          "artist-name": "Adele",
      }
      jsonData, _ := json.Marshal(body)

      req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
      if err != nil {
          panic(err)
      }

      req.Header.Set("Authorization", "Bearer " + LOGIC_API_TOKEN)
      req.Header.Set("Content-Type", "application/json")

      client := &http.Client{}
      resp, err := client.Do(req)
      if err != nil {
          panic(err)
      }
      defer resp.Body.Close()

      responseBody, err := ioutil.ReadAll(resp.Body)
      if err != nil {
          panic(err)
      }

      fmt.Println(string(responseBody))
  }
  ```

  ```java java theme={null}
  // Java requires the OkHttp library. You can add it to your project using Maven or Gradle. Learn more in the Java Quick Start section of the API reference.

  import okhttp3.*;
  import java.io.IOException;

  public class Main {
      public static void main(String[] args) throws IOException {
          OkHttpClient client = new OkHttpClient();

          String json = "{\"artist-name\": \"Adele\"}";
          RequestBody body = RequestBody.create(json, MediaType.get("application/json"));

          Request request = new Request.Builder()
              .url("https://api.logic.inc/v1/agents/summarize-music-artist-profile/executions")
              .addHeader("Authorization", "Bearer ls-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
              .addHeader("Content-Type", "application/json")
              .post(body)
              .build();

          try (Response response = client.newCall(request).execute()) {
              if (!response.isSuccessful()) {
                  System.err.println("Request failed: " + response.code());
                  return;
              }

              System.out.println(response.body().string());
          }
      }
  }
  ```
</CodeGroup>

<Info>
  This would succeed, as strict mode is off by default.

  Even though the input variable is supposed to be called `artistName`, the Logic API will adapt to the input and return a response.
</Info>

#### Strict Mode On

The same request fails when strict mode is **on**, because the input doesn't match the schema.

<CodeGroup>
  ```bash curl theme={null}
  curl -X POST 'https://api.logic.inc/v1/agents/summarize-music-artist-profile/executions?enforceInputSchema=true'
    -H "Authorization: Bearer $LOGIC_API_TOKEN"
    -H "Content-Type: application/json"
    -d '{
          "artist-name": "Adele"
        }'
  ```

  ```bash httpie theme={null}
  http POST https://api.logic.inc/v1/agents/summarize-music-artist-profile/executions
    enforceInputSchema==true
    "Authorization:Bearer $LOGIC_API_TOKEN"
    "Content-Type:application/json"
    artist-name="Adele"
  ```

  ```python python theme={null}
  import requests
  import json

  url = "https://api.logic.inc/v1/agents/summarize-music-artist-profile/executions"
  params = {
      "enforceInputSchema": "true"
  }
  headers = {
      "Authorization": "Bearer ls-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
      "Content-Type": "application/json"
  }
  data = {
      "artist-name": "Adele"
  }

  response = requests.post(url, params=params, headers=headers, data=json.dumps(data))
  print(response.status_code, response.text)
  ```

  ```ruby ruby theme={null}
  require 'net/http'
  require 'json'

  uri = URI('https://api.logic.inc/v1/agents/summarize-music-artist-profile/executions')
  uri.query = URI.encode_www_form({enforceInputSchema: "true" })

  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true

  LOGIC_API_TOKEN = 'ls-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
  headers = {
    "Authorization" => "Bearer #{LOGIC_API_TOKEN}",
    "Content-Type" => "application/json"
  }
  body = { "artist-name" => "Adele" }.to_json

  request = Net::HTTP::Post.new(uri, headers)
  request.body = body

  response = http.request(request)
  puts response.code
  puts response.body
  ```

  ```javascript javascript theme={null}
  const LOGIC_API_TOKEN = "ls-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";

  const url = new URL(
    "https://api.logic.inc/v1/agents/summarize-music-artist-profile/executions",
  );
  url.searchParams.set("enforceInputSchema", "true");

  fetch(url, {
    method: "POST",
    headers: {
      Authorization: `Bearer ${LOGIC_API_TOKEN}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({ "artist-name": "Adele" }),
  })
    .then((res) => res.text())
    .then(console.log)
    .catch(console.error);
  ```

  ```go go theme={null}
  package main

  import (
      "bytes"
      "encoding/json"
      "fmt"
      "net/http"
      "io/ioutil"
  )

  const (
      LOGIC_API_TOKEN = "ls-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  )

  func main() {
      url := "https://api.logic.inc/v1/agents/summarize-music-artist-profile/executions?enforceInputSchema=true"

      body := map[string]string{
          "artist-name": "Adele",
      }
      jsonData, _ := json.Marshal(body)

      req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
      if err != nil {
          panic(err)
      }

      req.Header.Set("Authorization", "Bearer "+LOGIC_API_TOKEN)
      req.Header.Set("Content-Type", "application/json")

      client := &http.Client{}
      resp, err := client.Do(req)
      if err != nil {
          panic(err)
      }
      defer resp.Body.Close()

      responseBody, err := ioutil.ReadAll(resp.Body)
      if err != nil {
          panic(err)
      }

      fmt.Println(string(responseBody))
  }
  ```

  ```java java theme={null}
  // Java requires the OkHttp library. You can add it to your project using Maven or Gradle. Learn more in the Java Quick Start section of the API reference.

  import okhttp3.*;
  import java.io.IOException;

  public class Main {
      public static void main(String[] args) throws IOException {
          OkHttpClient client = new OkHttpClient();

          String json = "{\"artist-name\": \"Adele\"}";
          RequestBody body = RequestBody.create(json, MediaType.get("application/json"));

          HttpUrl url = HttpUrl.parse("https://api.logic.inc/v1/agents/summarize-music-artist-profile/executions")
              .newBuilder()
              .addQueryParameter("enforceInputSchema", "true")
              .build();

          Request request = new Request.Builder()
              .url(url)
              .addHeader("Authorization", "Bearer ls-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
              .addHeader("Content-Type", "application/json")
              .post(body)
              .build();

          try (Response response = client.newCall(request).execute()) {
              if (!response.isSuccessful()) {
                  System.err.println("Request failed: " + response.code());
                  return;
              }

              System.out.println(response.body().string());
          }
      }
  }
  ```
</CodeGroup>

<Info>
  This would fail, as strict mode is on and the input does not match the input schema.

  The Logic API will not adapt to the input and will return an error.
</Info>
