RunpodR
Runpod3mo ago
Paul

How to get the IP address of a running pod via API

EDIT: I see someone else asked something similar more than 30 days ago, with no answer. Hopefully I can get one this time!

I'm writing a tool to manage pods to run LLMs, which I will then access from VSCode.

Much of it is working

With the API, I can create pods with a specified template, query their status etc. But I can't connect to them (from the code) because whenever I query the IP address, it returns "null"

See the curl command below. I can see the IP address in the Web UI under "Direct TCP Ports" so it has been assigned.

How do I get it with an API call?

curl https://api.runpod.io/graphql -H "Content-Type: application/json" -H "Authorization: Bearer rpa_xxx" -d '{
"query": "query { pod(input: { podId: "9boygy63ax7eaj" }) { id name desiredStatus imageName ipAddress { address } ports } }"
}'
{"data":{"pod":{"id":"9boygy63ax7eaj","name":"runpod-llm","desiredStatus":"RUNNING","imageName":"runpod/pytorch:1.0.1-cu1281-torch280-ubuntu2404","ipAddress":null,"ports":"8888/http,22/tcp,1234/tcp"}}}
Solution
response:
[
  {
    "adjustedCostPerHr": 0.69,
    "aiApiId": null,
    "consumerUserId": "user_2PyTJrLzeuwfZilRZ7JhCQDuSqo",
    "containerDiskInGb": 50,
    "containerRegistryAuthId": "clzdaifot0001l90809257ynb",
    "costPerHr": "0.74",
    "cpuFlavorId": "cpu3c",
    "desiredStatus": "RUNNING",
    "dockerEntrypoint": [
      "<string>"
    ],
    "dockerStartCmd": [
      "<string>"
    ],
....
    "publicIp": "100.65.0.119",
.... Simplified
}
]
Was this page helpful?