# How to pass trust\_remote\_code to API request?

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-pass-trust-remote-code-to-api-request%2F66458%3E%5C
**Category:** Beginners\
**Created:** [December 20, 2023, 10:54am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-pass-trust-remote-code-to-api-request%2F66458 "2023-12-20T10:54:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hacken4221](https://avatars.discourse-cdn.com/v4/letter/h/4af34b/32.png) [@hacken4221](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fhacken4221)%5C
**Post date:** [December 20, 2023, 10:54am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-pass-trust-remote-code-to-api-request%2F66458%2F1 "2023-12-20T10:54:47Z")

</div>

```auto
API_URL = "/static-proxy?url=https%3A%2F%2Fapi-inference.huggingface.co%2Fmodels%2Fmicrosoft%2Fphi-2"
headers = {"Authorization": f"Bearer {API_TOKEN}"}
def query(payload):
    response = requests.post(API_URL, headers=headers, json=payload)
    return response.json()
data = query({"inputs": prompt})
print(data)

```

Got an error

```auto
{'error': 'The repository for microsoft/phi-2 contains custom code which must be executed to correctly load the model. You can inspect the repository content at https://hf.co/microsoft/phi-2.\nPlease pass the argument `trust_remote_code=True` to allow custom code to be run.'}

```

How to fix this, how to pass the argument `trust_remote_code=True` ?

---

<div class="post-metadata">

**Author:** ![nielsr](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/nielsr/32/39617_2.png) [@nielsr](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fnielsr)%5C
**Post date:** [December 23, 2023, 11:14am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-pass-trust-remote-code-to-api-request%2F66458%2F2 "2023-12-23T11:14:36Z")

</div>

cc @osanseviero. The inference API does not support `trust_remote_code=True` for now.

---

<div class="post-metadata">

**Author:** ![YaphetYan](https://avatars.discourse-cdn.com/v4/letter/y/91b2a8/32.png) [@YaphetYan](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FYaphetYan)%5C
**Post date:** [July 10, 2024, 8:00am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-pass-trust-remote-code-to-api-request%2F66458%2F3 "2024-07-10T08:00:14Z")

</div>

got this error too

---

<div class="post-metadata">

**Author:** ![forrest-vectara](https://avatars.discourse-cdn.com/v4/letter/f/7ea924/32.png) [@forrest-vectara](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fforrest-vectara)%5C
**Post date:** [August 13, 2024, 1:47am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-pass-trust-remote-code-to-api-request%2F66458%2F4 "2024-08-13T01:47:39Z")

</div>

Has there been any update? We have a model that uses custom code. We really would love our users to use the Inference API widget to try out our model.
