# How to force the task of inference API?

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-force-the-task-of-inference-api%2F15853%3E%5C
**Category:** 🤗Hub\
**Created:** [March 18, 2022, 3:34pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-force-the-task-of-inference-api%2F15853 "2022-03-18T15:34:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![juancavallotti](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/juancavallotti/32/4976_2.png) [@juancavallotti](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fjuancavallotti)%5C
**Post date:** [March 18, 2022, 3:34pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-force-the-task-of-inference-api%2F15853%2F1 "2022-03-18T15:34:52Z")

</div>

Hello! I trained a model for zero-shot classification and in the pipelines it works great, but the inference api recognizes the task as text classification, and thus I can’t use it as zero-shot out of the box. Is there a way to hint the inference API to what task I want to use my model?

Thanks!

---

<div class="post-metadata">

**Author:** ![juancavallotti](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/juancavallotti/32/4976_2.png) [@juancavallotti](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fjuancavallotti)%5C
**Post date:** [March 18, 2022, 3:57pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-force-the-task-of-inference-api%2F15853%2F2 "2022-03-18T15:57:09Z")

</div>

Replying to self, and figured out after looking into the code of the InferenceAPI objects. You can pass the task type as a path parameter like `<<inference api base url>>/pipeline/task-type/model`. Leaving it here in case anyone has the same question.

---

<div class="post-metadata">

**Author:** ![mdroth](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/mdroth/32/29308_2.png) [@mdroth](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fmdroth)%5C
**Post date:** [April 11, 2024, 2:35pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-force-the-task-of-inference-api%2F15853%2F3 "2024-04-11T14:35:20Z")

</div>

Here is a more detailed example:

```auto
import requests
import numpy as np

API_URL = "/static-proxy?url=https%3A%2F%2Fapi-inference.huggingface.co%2Fpipeline%2Ffeature-extraction%2Fdeepset%2Froberta-base-squad2"
headers = {"Authorization": f"Bearer {HUGGINGFACE_TOKEN}"}

def query(payload):
    response = requests.post(API_URL, headers=headers, json=payload)
    return response.json()

data = query({"inputs": "This is a more detailed example."})
data = np.array(data)[0]
embedding = np.mean(data, axis=0)
len(embedding), embedding

```
