# Sam, cogvlm http request internal error

**URL:** <https://discuss.roboflow.com/t/sam-cogvlm-http-request-internal-error/5244>\
**Category:** 🤝  Community Help\
**Tags:** bugs\
**Created:** [April 11, 2024, 7:14am UTC](https://discuss.roboflow.com/t/sam-cogvlm-http-request-internal-error/5244 "2024-04-11T07:14:05Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![YoungjaeDev](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/youngjaedev/32/4020_2.png) [@YoungjaeDev](https://discuss.roboflow.com/u/YoungjaeDev)\
**Post date:** [April 11, 2024, 7:14am UTC](https://discuss.roboflow.com/t/sam-cogvlm-http-request-internal-error/5244/1 "2024-04-11T07:14:05Z")

</div>

_Describe your question/issue here! (delete this when you post)_

- **Project Type:**
- **Operating System & Browser:**
- **Project Universe Link or Workspace/Project ID:**

```bash
Traceback (most recent call last):
  File "/home/aicads/miniconda3/envs/vlm/lib/python3.8/site-packages/inference_sdk/http/client.py", line 82, in decorate
    return function(*args, **kwargs)
  File "/home/aicads/miniconda3/envs/vlm/lib/python3.8/site-packages/inference_sdk/http/client.py", line 717, in prompt_cogvlm
    api_key_safe_raise_for_status(response=response)
  File "/home/aicads/miniconda3/envs/vlm/lib/python3.8/site-packages/inference_sdk/http/utils/requests.py", line 16, in api_key_safe_raise_for_status
    response.raise_for_status()
  File "/home/aicads/miniconda3/envs/vlm/lib/python3.8/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: http://localhost:9001/llm/cogvlm

```

sam and cogvlm got same error [500]

---

<div class="post-metadata">

**Author:** ![YoungjaeDev](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/youngjaedev/32/4020_2.png) [@YoungjaeDev](https://discuss.roboflow.com/u/YoungjaeDev)\
**Post date:** [April 11, 2024, 7:19am UTC](https://discuss.roboflow.com/t/sam-cogvlm-http-request-internal-error/5244/2 "2024-04-11T07:19:52Z")

</div>

```python
import requests

infer_payload = {
    "image": {
        "type": "base64",
        "value": "https://i.imgur.com/Q6lDy8B.jpg",
    },
    "image_id": "example_image_id",
}

base_url = "http://localhost:9001"

# Define your Roboflow API Key
api_key = "YOUR ROBOFLOW API KEY"

res = requests.post(
    f"{base_url}/sam/embed_image?api_key={api_key}",
    json=infer_payload,
)

embeddings = res.json()['embeddings']

```

I’m getting a 500 error even with the basic example, is the api-key the problem?

---

<div class="post-metadata">

**Author:** ![Jacob\_Witt](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/jacob_witt/32/347_2.png) [@Jacob\_Witt](https://discuss.roboflow.com/u/Jacob_Witt)\
**Post date:** [April 11, 2024, 12:52pm UTC](https://discuss.roboflow.com/t/sam-cogvlm-http-request-internal-error/5244/3 "2024-04-11T12:52:13Z")

</div>

Just to clarify - you are populating your own API key in that variable, correct?

---

<div class="post-metadata">

**Author:** ![p.peczek](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/p.peczek/32/4168_2.png) [@p.peczek](https://discuss.roboflow.com/u/p.peczek)\
**Post date:** [April 11, 2024, 2:15pm UTC](https://discuss.roboflow.com/t/sam-cogvlm-http-request-internal-error/5244/4 "2024-04-11T14:15:47Z")

</div>

> [@YoungjaeDev](#):
>
> ```auto
> infer_payload = {
> "image": {
> "type": "base64",
> "value": "https://i.imgur.com/Q6lDy8B.jpg",
> },
> "image_id": "example_image_id",
> }
> 
> base_url = "http://localhost:9001"
> 
> # Define your Roboflow API Key
> api_key = "YOUR ROBOFLOW API KEY"
> 
> res = requests.post(
> f"{base_url}/sam/embed_image?api_key={api_key}",
> json=infer_payload,
> )
> 
> embeddings = res.json()['embeddings']
> 
> ```

Could u try out this:

```python
infer_payload = {
    "image": {
        "type": "url",
        "value": "https://t3.ftcdn.net/jpg/01/73/37/16/360_F_173371622_02A2qGqjhsJ5SWVhUPu0t9O9ezlfvF8l.jpg",
    },
    "image_id": "example_image_id",
}

base_url = "http://localhost:9001"

# Define your Roboflow API Key
API_KEY = "YOUR ROBOFLOW API KEY"

res = requests.post(
    f"{base_url}/sam/embed_image?api_key={API_KEY}",
    json=infer_payload,
)

embeddings = res.json()['embeddings']

```

This works for me

---

<div class="post-metadata">

**Author:** ![YoungjaeDev](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/youngjaedev/32/4020_2.png) [@YoungjaeDev](https://discuss.roboflow.com/u/YoungjaeDev)\
**Post date:** [April 11, 2024, 2:19pm UTC](https://discuss.roboflow.com/t/sam-cogvlm-http-request-internal-error/5244/5 "2024-04-11T14:19:19Z")

</div>

Yes. Even though I deleted and reissued the key, the problem arose.

---

<div class="post-metadata">

**Author:** ![YoungjaeDev](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/youngjaedev/32/4020_2.png) [@YoungjaeDev](https://discuss.roboflow.com/u/YoungjaeDev)\
**Post date:** [April 11, 2024, 2:42pm UTC](https://discuss.roboflow.com/t/sam-cogvlm-http-request-internal-error/5244/6 "2024-04-11T14:42:37Z")

</div>

@Jacob_Witt

The inference server is up and connected to its own local, but I’m wondering, I think I have 3 workspaces, all of them are public or sandbox plan, so I don’t know which API\_KEY to choose, hmm what about the API\_KEY if it’s its own server?

![image](https://canada1.discourse-cdn.com/flex029/uploads/roboflow1/original/2X/4/4b81c384efb3462118b6cac8066dfce141f00141.png)

---

<div class="post-metadata">

**Author:** ![YoungjaeDev](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/youngjaedev/32/4020_2.png) [@YoungjaeDev](https://discuss.roboflow.com/u/YoungjaeDev)\
**Post date:** [April 11, 2024, 2:43pm UTC](https://discuss.roboflow.com/t/sam-cogvlm-http-request-internal-error/5244/7 "2024-04-11T14:43:16Z")

</div>

![image](https://canada1.discourse-cdn.com/flex029/uploads/roboflow1/original/2X/9/92d1cb866b6947b6cee47e0830254c21299d908b.jpeg)

---

<div class="post-metadata">

**Author:** ![p.peczek](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/p.peczek/32/4168_2.png) [@p.peczek](https://discuss.roboflow.com/u/p.peczek)\
**Post date:** [April 11, 2024, 4:13pm UTC](https://discuss.roboflow.com/t/sam-cogvlm-http-request-internal-error/5244/8 "2024-04-11T16:13:43Z")

</div>

Could you share with us logs from the server  
Use `docker ps` to find running containers id  
Then `docker logs -f <container_id>` to retrieve logs

---

<div class="post-metadata">

**Author:** ![Jacob\_Witt](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/jacob_witt/32/347_2.png) [@Jacob\_Witt](https://discuss.roboflow.com/u/Jacob_Witt)\
**Post date:** [April 11, 2024, 6:02pm UTC](https://discuss.roboflow.com/t/sam-cogvlm-http-request-internal-error/5244/9 "2024-04-11T18:02:22Z")

</div>

You should use the API from the workspace where the model is hosted

---

<div class="post-metadata">

**Author:** ![YoungjaeDev](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/youngjaedev/32/4020_2.png) [@YoungjaeDev](https://discuss.roboflow.com/u/YoungjaeDev)\
**Post date:** [April 12, 2024, 12:42am UTC](https://discuss.roboflow.com/t/sam-cogvlm-http-request-internal-error/5244/10 "2024-04-12T00:42:52Z")

</div>

w/ @p.peczek

Sorry, I’m new to the infernece package and I’m sure I’m confused about something.  
I installed inference server on my personal server, not in cloud form like roboflow, aws, etc.  
So my thought is that the roboflow api-key has nothing to do with the 3 workspaces captured above, but how do I match the key… The model itself seems to be downloaded inside docker

**In other words, what API\_KEY could be associated with a workspace in internal Docker?**

here is docker log

```bash
INFO: 172.17.0.1:35882 - "GET / HTTP/1.1" 304 Not Modified
Traceback (most recent call last):
  File "/app/inference/core/interfaces/http/http_api.py", line 163, in wrapped_route
    return await route(*args, **kwargs)
  File "/app/inference/core/interfaces/http/http_api.py", line 1079, in sam_embed_image
    model_response = await self.model_manager.infer_from_request(
  File "/app/inference/core/managers/decorators/fixed_size_cache.py", line 91, in infer_from_request
    return await super().infer_from_request(model_id, request, **kwargs)
  File "/app/inference/core/managers/decorators/base.py", line 69, in infer_from_request
    return await self.model_manager.infer_from_request(model_id, request, **kwargs)
  File "/app/inference/core/managers/active_learning.py", line 147, in infer_from_request
    prediction = await super().infer_from_request(
  File "/app/inference/core/managers/active_learning.py", line 35, in infer_from_request
    prediction = await super().infer_from_request(
  File "/app/inference/core/managers/base.py", line 95, in infer_from_request
    rtn_val = await self.model_infer(
  File "/app/inference/core/managers/base.py", line 152, in model_infer
    return self._models[model_id].infer_from_request(request)
  File "/app/inference/models/sam/segment_anything.py", line 134, in infer_from_request
    embedding, _ = self.embed_image(**request.dict())
  File "/app/inference/models/sam/segment_anything.py", line 110, in embed_image
    img_in = self.preproc_image(image)
  File "/app/inference/models/sam/segment_anything.py", line 181, in preproc_image
    np_image = load_image_rgb(image)
  File "/app/inference/core/utils/image_utils.py", line 42, in load_image_rgb
    np_image, is_bgr = load_image(
  File "/app/inference/core/utils/image_utils.py", line 81, in load_image
    np_image, is_bgr = load_image_with_known_type(
  File "/app/inference/core/utils/image_utils.py", line 164, in load_image_with_known_type
    image = loader(value, cv_imread_flags)
  File "/app/inference/core/utils/image_utils.py", line 255, in load_image_base64
    value = pybase64.b64decode(value)
binascii.Error: Incorrect padding
INFO: 172.17.0.1:40558 - "POST /sam/embed_image?api_key=2pKBv3TsNPQAmJm6AMzm HTTP/1.1" 500 Internal Server Error

```

Thank you

---

<div class="post-metadata">

**Author:** ![p.peczek](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/p.peczek/32/4168_2.png) [@p.peczek](https://discuss.roboflow.com/u/p.peczek)\
**Post date:** [April 12, 2024, 8:06am UTC](https://discuss.roboflow.com/t/sam-cogvlm-http-request-internal-error/5244/11 "2024-04-12T08:06:14Z")

</div>

ok, this is something I expected, as our example has a bug.

error `binascii.Error: Incorrect padding` comes from:

```auto
    "image": {
        "type": "base64",
        "value": "https://i.imgur.com/Q6lDy8B.jpg",
    },

```

where we wrongly suggested to provide image type (which is link) to be type `base64`. The image itself also does not load due to hosting issue.

I provided you this example:

```auto
infer_payload = {
    "image": {
        "type": "url",
        "value": "https://t3.ftcdn.net/jpg/01/73/37/16/360_F_173371622_02A2qGqjhsJ5SWVhUPu0t9O9ezlfvF8l.jpg",
    },
    "image_id": "example_image_id",
}

base_url = "http://localhost:9001"

# Define your Roboflow API Key
API_KEY = "YOUR ROBOFLOW API KEY"

res = requests.post(
    f"{base_url}/sam/embed_image?api_key={API_KEY}",
    json=infer_payload,
)

embeddings = res.json()['embeddings']

```

could you please try it out?

---

<div class="post-metadata">

**Author:** ![YoungjaeDev](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/youngjaedev/32/4020_2.png) [@YoungjaeDev](https://discuss.roboflow.com/u/YoungjaeDev)\
**Post date:** [April 13, 2024, 3:27am UTC](https://discuss.roboflow.com/t/sam-cogvlm-http-request-internal-error/5244/12 "2024-04-13T03:27:10Z")

</div>

working well…

But I’m curious, doesn’t the api-key have any meaning when doing it locally?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex029/uploads/roboflow1/original/1X/bb6edbfa56d0cf2ee603f061e9e09103502cc8cc.png) [@system](https://discuss.roboflow.com/u/system)\
**Post date:** [May 4, 2024, 3:27am UTC](https://discuss.roboflow.com/t/sam-cogvlm-http-request-internal-error/5244/13 "2024-05-04T03:27:28Z")

</div>

Closed on May 4, 2024, 3:27am UTC

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.
